1 /* $NetBSD: scan.l,v 1.14 2004/08/02 21:29:07 dsl Exp $ */
4 * Copyright 1997 Piermont Information Systems Inc.
7 * Written by Philip A. Nelson for Piermont Information Systems Inc.
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
17 * 3. All advertising materials mentioning features or use of this software
18 * must display the following acknowledgement:
19 * This product includes software develooped for the NetBSD Project by
20 * Piermont Information Systems Inc.
21 * 4. The name of Piermont Information Systems Inc. may not be used to endorse
22 * or promote products derived from this software without specific prior
25 * THIS SOFTWARE IS PROVIDED BY PIERMONT INFORMATION SYSTEMS INC. ``AS IS''
26 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
28 * ARE DISCLAIMED. IN NO EVENT SHALL PIERMONT INFORMATION SYSTEMS INC. BE
29 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
30 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
31 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
32 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
33 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
34 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
35 * THE POSSIBILITY OF SUCH DAMAGE.
40 /* scan.l: scanner description for menu compiler. */
47 static int level; /* For nested comments. */
48 static int comstart; /* line number of comment start. */
59 [ \t]+ { /* ignore spaces and tabs */ }
63 "="|";"|","|"("|")" { return (int)yytext[0]; }
83 menus { return MENUS; }
89 exitstring { return EXITSTRING; }
91 title { return TITLE; }
93 action { return ACTION; }
95 endwin { return ENDWIN; }
97 option { return OPTION; }
99 default { return DEFAULT; }
101 display { return DISPLAY; }
103 error { return ERROR; }
105 allow { return ALLOW; }
107 dynamic { return DYNAMIC; }
109 messages { return MESSAGES; }
111 scrollable { return SCROLLABLE; }
113 shortcut { return SHORTCUT; }
115 clear { return CLEAR; }
117 always { return ALWAYS; }
119 scroll { return SCROLL; }
121 \"([^\"\n]*(\\\")?)*\" {
122 yylval.s_value = strdup (yytext);
123 max_strlen = max_strlen > strlen(yytext)
124 ? max_strlen : strlen(yytext) + 1;
128 [a-zA-Z][a-zA-Z0-9_]* {
129 yylval.s_value = strdup(yytext);
134 yylval.s_value = strdup(yytext);
138 "'"[^'\\]|(\\[athrn])|(\\[0-9][0-9]?[0-9]?)"'" {
139 yylval.s_value = strdup(yytext);
143 "/*" { level = 1; comstart = line_no; BEGIN COMMENT; }
145 <COMMENT>"/*" { level++; }
147 <COMMENT>"*/" { if (level-- == 1) BEGIN 0; }
149 <COMMENT>"\n" { line_no++; }
152 yyerror ("EOF inside a comment that started at line %d",
157 <COMMENT>. {/* eat character */}
159 "{" { level = 1; BEGIN BRACE; }
161 <BRACE>"{" { buff_add_ch(yytext[0]); level++; }
163 <BRACE>"}" { if (level-- == 1) {
165 yylval.s_value = buff_copy();
168 buff_add_ch (yytext[0]);
171 <BRACE>"\n" { buff_add_ch (yytext[0]); line_no++; }
173 <BRACE>. { buff_add_ch (yytext[0]); }
177 yyerror ("illegal character: ^%c",yytext[0] + '@');
180 yyerror ("illegal character: \\%3d", (int) yytext[0]);
182 yyerror ("illegal character: %s",yytext);
184 /* To quiet the compiler */
197 while ( (val = yylex()) != 0 )
198 printf ("val = %d\n yytext = %s\n", val, yytext);