Deleted Added
full compact
scan.l (2258) scan.l (16514)
1/* scan.l - scanner for flex input */
2
3%{
4/*-
5 * Copyright (c) 1990 The Regents of the University of California.
6 * All rights reserved.
7 *
8 * This code is derived from software contributed to Berkeley by

--- 13 unchanged lines hidden (view full) ---

22 * Neither the name of the University nor the names of its contributors may
23 * be used to endorse or promote products derived from this software without
24 * specific prior written permission.
25 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
26 * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
27 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
28 */
29
1/* scan.l - scanner for flex input */
2
3%{
4/*-
5 * Copyright (c) 1990 The Regents of the University of California.
6 * All rights reserved.
7 *
8 * This code is derived from software contributed to Berkeley by

--- 13 unchanged lines hidden (view full) ---

22 * Neither the name of the University nor the names of its contributors may
23 * be used to endorse or promote products derived from this software without
24 * specific prior written permission.
25 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
26 * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
27 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
28 */
29
30/* $Header: scan.l,v 1.2 94/01/04 14:33:09 vern Exp $ */
30/* $Header: /home/daffy/u0/vern/flex/RCS/scan.l,v 2.56 95/04/24 12:17:19 vern Exp $ */
31
32#include "flexdef.h"
33#include "parse.h"
34
35#define ACTION_ECHO add_action( yytext )
31
32#include "flexdef.h"
33#include "parse.h"
34
35#define ACTION_ECHO add_action( yytext )
36#define ACTION_IFDEF(def, should_define) \
37 { \
38 if ( should_define ) \
39 action_define( def, 1 ); \
40 }
41
36#define MARK_END_OF_PROLOG mark_prolog();
37
38#define YY_DECL \
39 int flexscan()
40
41#define RETURNCHAR \
42 yylval = (unsigned char) yytext[0]; \
43 return CHAR;

--- 10 unchanged lines hidden (view full) ---

54 if ( all_upper( str ) ) \
55 reject = true;
56
57#define CHECK_YYMORE(str) \
58 if ( all_lower( str ) ) \
59 yymore_used = true;
60%}
61
42#define MARK_END_OF_PROLOG mark_prolog();
43
44#define YY_DECL \
45 int flexscan()
46
47#define RETURNCHAR \
48 yylval = (unsigned char) yytext[0]; \
49 return CHAR;

--- 10 unchanged lines hidden (view full) ---

60 if ( all_upper( str ) ) \
61 reject = true;
62
63#define CHECK_YYMORE(str) \
64 if ( all_lower( str ) ) \
65 yymore_used = true;
66%}
67
68%option caseless nodefault outfile="scan.c" stack noyy_top_state
69%option nostdinit
70
62%x SECT2 SECT2PROLOG SECT3 CODEBLOCK PICKUPDEF SC CARETISBOL NUM QUOTE
71%x SECT2 SECT2PROLOG SECT3 CODEBLOCK PICKUPDEF SC CARETISBOL NUM QUOTE
63%x FIRSTCCL CCL ACTION RECOVER BRACEERROR C_COMMENT ACTION_COMMENT
64%x ACTION_STRING PERCENT_BRACE_ACTION USED_LIST CODEBLOCK_2
72%x FIRSTCCL CCL ACTION RECOVER COMMENT ACTION_STRING PERCENT_BRACE_ACTION
73%x OPTION LINEDIR
65
74
66WS [ \t]+
67OPTWS [ \t]*
68NOT_WS [^ \t\n]
75WS [[:blank:]]+
76OPTWS [[:blank:]]*
77NOT_WS [^[:blank:]\n]
69
78
70NL (\n|\r\n|\n\r)
79NL \r?\n
71
80
72NAME ([a-z_][a-z_0-9-]*)
73NOT_NAME [^a-z_*\n]+
81NAME ([[:alpha:]_][[:alnum:]_-]*)
82NOT_NAME [^[:alpha:]_*\n]+
74
75SCNAME {NAME}
76
83
84SCNAME {NAME}
85
77ESCSEQ (\\([^\n]|[0-9]{1,3}|x[0-9a-f]{1,2}))
86ESCSEQ (\\([^\n]|[0-7]{1,3}|x[[:xdigit:]]{1,2}))
78
79FIRST_CCL_CHAR ([^\\\n]|{ESCSEQ})
80CCL_CHAR ([^\\\n\]]|{ESCSEQ})
87
88FIRST_CCL_CHAR ([^\\\n]|{ESCSEQ})
89CCL_CHAR ([^\\\n\]]|{ESCSEQ})
90CCL_EXPR ("[:"[[:alpha:]]+":]")
81
91
92LEXOPT [aceknopr]
93
82%%
94%%
83 static int bracelevel, didadef, indented_code, checking_used;
95 static int bracelevel, didadef, indented_code;
96 static int doing_rule_action = false;
97 static int option_sense;
84
85 int doing_codeblock = false;
86 int i;
87 Char nmdef[MAXLINE], myesc();
88
89
98
99 int doing_codeblock = false;
100 int i;
101 Char nmdef[MAXLINE], myesc();
102
103
90^{WS} indented_code = true; BEGIN(CODEBLOCK);
91^"/*" ACTION_ECHO; BEGIN(C_COMMENT);
92^"%s"{NAME}? return SCDECL;
93^"%x"{NAME}? return XSCDECL;
94^"%{".*{NL} {
104<INITIAL>{
105 ^{WS} indented_code = true; BEGIN(CODEBLOCK);
106 ^"/*" ACTION_ECHO; yy_push_state( COMMENT );
107 ^#{OPTWS}line{WS} yy_push_state( LINEDIR );
108 ^"%s"{NAME}? return SCDECL;
109 ^"%x"{NAME}? return XSCDECL;
110 ^"%{".*{NL} {
95 ++linenum;
111 ++linenum;
96 line_directive_out( (FILE *) 0 );
112 line_directive_out( (FILE *) 0, 1 );
97 indented_code = false;
98 BEGIN(CODEBLOCK);
99 }
100
113 indented_code = false;
114 BEGIN(CODEBLOCK);
115 }
116
101{WS} return WHITESPACE;
117 {WS} /* discard */
102
118
103^"%%".* {
119 ^"%%".* {
104 sectnum = 2;
105 bracelevel = 0;
106 mark_defs1();
120 sectnum = 2;
121 bracelevel = 0;
122 mark_defs1();
107 line_directive_out( (FILE *) 0 );
123 line_directive_out( (FILE *) 0, 1 );
108 BEGIN(SECT2PROLOG);
109 return SECTEND;
110 }
111
124 BEGIN(SECT2PROLOG);
125 return SECTEND;
126 }
127
112^"%pointer".*{NL} {
113 if ( lex_compat )
114 warn( "%pointer incompatible with -l option" );
115 else
116 yytext_is_array = false;
117 ++linenum;
118 }
119^"%array".*{NL} {
120 if ( C_plus_plus )
121 warn( "%array incompatible with -+ option" );
122 else
123 yytext_is_array = true;
124 ++linenum;
125 }
128 ^"%pointer".*{NL} yytext_is_array = false; ++linenum;
129 ^"%array".*{NL} yytext_is_array = true; ++linenum;
126
130
127^"%used" {
128 warn( "%used/%unused have been deprecated" );
129 checking_used = REALLY_USED; BEGIN(USED_LIST);
130 }
131^"%unused" {
132 warn( "%used/%unused have been deprecated" );
133 checking_used = REALLY_NOT_USED; BEGIN(USED_LIST);
134 }
131 ^"%option" BEGIN(OPTION); return OPTION_OP;
135
132
133 ^"%"{LEXOPT}{OPTWS}[[:digit:]]*{OPTWS}{NL} ++linenum; /* ignore */
134 ^"%"{LEXOPT}{WS}.*{NL} ++linenum; /* ignore */
136
135
137^"%"[aceknopr]{OPTWS}[0-9]*{OPTWS}{NL} ++linenum; /* ignore */
136 ^"%"[^sxaceknopr{}].* synerr( _( "unrecognized '%' directive" ) );
138
137
139^"%"[^sxanpekotcru{}].* synerr( "unrecognized '%' directive" );
140
141^{NAME} {
138 ^{NAME} {
142 strcpy( nmstr, yytext );
143 didadef = false;
144 BEGIN(PICKUPDEF);
145 }
146
139 strcpy( nmstr, yytext );
140 didadef = false;
141 BEGIN(PICKUPDEF);
142 }
143
147{SCNAME} RETURNNAME;
148^{OPTWS}{NL} ++linenum; /* allows blank lines in section 1 */
149{OPTWS}{NL} ++linenum; return '\n';
144 {SCNAME} RETURNNAME;
145 ^{OPTWS}{NL} ++linenum; /* allows blank lines in section 1 */
146 {OPTWS}{NL} ACTION_ECHO; ++linenum; /* maybe end of comment line */
147}
150
151
148
149
152<C_COMMENT>"*/" ACTION_ECHO; BEGIN(INITIAL);
153<C_COMMENT>"*/".*{NL} ++linenum; ACTION_ECHO; BEGIN(INITIAL);
154<C_COMMENT>[^*\n]+ ACTION_ECHO;
155<C_COMMENT>"*" ACTION_ECHO;
156<C_COMMENT>{NL} ++linenum; ACTION_ECHO;
150<COMMENT>{
151 "*/" ACTION_ECHO; yy_pop_state();
152 "*" ACTION_ECHO;
153 [^*\n]+ ACTION_ECHO;
154 [^*\n]*{NL} ++linenum; ACTION_ECHO;
155}
157
156
157<LINEDIR>{
158 \n yy_pop_state();
159 [[:digit:]]+ linenum = myctoi( yytext );
158
160
159<CODEBLOCK>^"%}".*{NL} ++linenum; BEGIN(INITIAL);
160<CODEBLOCK>"reject" ACTION_ECHO; CHECK_REJECT(yytext);
161<CODEBLOCK>"yymore" ACTION_ECHO; CHECK_YYMORE(yytext);
162<CODEBLOCK>{NAME}|{NOT_NAME}|. ACTION_ECHO;
163<CODEBLOCK>{NL} {
161 \"[^"\n]*\" {
162 flex_free( (void *) infilename );
163 infilename = copy_string( yytext + 1 );
164 infilename[strlen( infilename ) - 1] = '\0';
165 }
166 . /* ignore spurious characters */
167}
168
169<CODEBLOCK>{
170 ^"%}".*{NL} ++linenum; BEGIN(INITIAL);
171
172 {NAME}|{NOT_NAME}|. ACTION_ECHO;
173
174 {NL} {
164 ++linenum;
165 ACTION_ECHO;
166 if ( indented_code )
167 BEGIN(INITIAL);
168 }
175 ++linenum;
176 ACTION_ECHO;
177 if ( indented_code )
178 BEGIN(INITIAL);
179 }
180}
169
170
181
182
171<PICKUPDEF>{WS} /* separates name and definition */
183{
184 {WS} /* separates name and definition */
172
185
173<PICKUPDEF>{NOT_WS}.* {
186 {NOT_WS}.* {
174 strcpy( (char *) nmdef, yytext );
175
176 /* Skip trailing whitespace. */
177 for ( i = strlen( (char *) nmdef ) - 1;
178 i >= 0 && (nmdef[i] == ' ' || nmdef[i] == '\t');
179 --i )
180 ;
181
182 nmdef[i + 1] = '\0';
183
184 ndinstal( nmstr, nmdef );
185 didadef = true;
186 }
187
187 strcpy( (char *) nmdef, yytext );
188
189 /* Skip trailing whitespace. */
190 for ( i = strlen( (char *) nmdef ) - 1;
191 i >= 0 && (nmdef[i] == ' ' || nmdef[i] == '\t');
192 --i )
193 ;
194
195 nmdef[i + 1] = '\0';
196
197 ndinstal( nmstr, nmdef );
198 didadef = true;
199 }
200
188<PICKUPDEF>{NL} {
201 {NL} {
189 if ( ! didadef )
202 if ( ! didadef )
190 synerr( "incomplete name definition" );
203 synerr( _( "incomplete name definition" ) );
191 BEGIN(INITIAL);
192 ++linenum;
193 }
204 BEGIN(INITIAL);
205 ++linenum;
206 }
207}
194
208
195<RECOVER>.*{NL} ++linenum; BEGIN(INITIAL); RETURNNAME;
196
209
210<OPTION>{
211 {NL} ++linenum; BEGIN(INITIAL);
212 {WS} option_sense = true;
197
213
198<USED_LIST>{NL} ++linenum; BEGIN(INITIAL);
199<USED_LIST>{WS}
200<USED_LIST>"reject" {
201 if ( all_upper( yytext ) )
202 reject_really_used = checking_used;
203 else
204 synerr(
205 "unrecognized %used/%unused construct" );
214 "=" return '=';
215
216 no option_sense = ! option_sense;
217
218 7bit csize = option_sense ? 128 : 256;
219 8bit csize = option_sense ? 256 : 128;
220
221 align long_align = option_sense;
222 always-interactive {
223 action_define( "YY_ALWAYS_INTERACTIVE", option_sense );
206 }
224 }
207<USED_LIST>"yymore" {
208 if ( all_lower( yytext ) )
209 yymore_really_used = checking_used;
210 else
211 synerr(
212 "unrecognized %used/%unused construct" );
225 array yytext_is_array = option_sense;
226 backup backing_up_report = option_sense;
227 batch interactive = ! option_sense;
228 "c++" C_plus_plus = option_sense;
229 caseful|case-sensitive caseins = ! option_sense;
230 caseless|case-insensitive caseins = option_sense;
231 debug ddebug = option_sense;
232 default spprdflt = ! option_sense;
233 ecs useecs = option_sense;
234 fast {
235 useecs = usemecs = false;
236 use_read = fullspd = true;
213 }
237 }
214<USED_LIST>{NOT_WS}+ synerr( "unrecognized %used/%unused construct" );
238 full {
239 useecs = usemecs = false;
240 use_read = fulltbl = true;
241 }
242 input ACTION_IFDEF("YY_NO_INPUT", ! option_sense);
243 interactive interactive = option_sense;
244 lex-compat lex_compat = option_sense;
245 main {
246 action_define( "YY_MAIN", option_sense );
247 do_yywrap = ! option_sense;
248 }
249 meta-ecs usemecs = option_sense;
250 never-interactive {
251 action_define( "YY_NEVER_INTERACTIVE", option_sense );
252 }
253 perf-report performance_report += option_sense ? 1 : -1;
254 pointer yytext_is_array = ! option_sense;
255 read use_read = option_sense;
256 reject reject_really_used = option_sense;
257 stack action_define( "YY_STACK_USED", option_sense );
258 stdinit do_stdinit = option_sense;
259 stdout use_stdout = option_sense;
260 unput ACTION_IFDEF("YY_NO_UNPUT", ! option_sense);
261 verbose printstats = option_sense;
262 warn nowarn = ! option_sense;
263 yylineno do_yylineno = option_sense;
264 yymore yymore_really_used = option_sense;
265 yywrap do_yywrap = option_sense;
215
266
267 yy_push_state ACTION_IFDEF("YY_NO_PUSH_STATE", ! option_sense);
268 yy_pop_state ACTION_IFDEF("YY_NO_POP_STATE", ! option_sense);
269 yy_top_state ACTION_IFDEF("YY_NO_TOP_STATE", ! option_sense);
216
270
217<SECT2PROLOG>^"%{".* ++bracelevel; yyless( 2 ); /* eat only %{ */
218<SECT2PROLOG>^"%}".* --bracelevel; yyless( 2 ); /* eat only %} */
271 yy_scan_buffer ACTION_IFDEF("YY_NO_SCAN_BUFFER", ! option_sense);
272 yy_scan_bytes ACTION_IFDEF("YY_NO_SCAN_BYTES", ! option_sense);
273 yy_scan_string ACTION_IFDEF("YY_NO_SCAN_STRING", ! option_sense);
219
274
220<SECT2PROLOG>^{WS}.* ACTION_ECHO; /* indented code in prolog */
275 outfile return OPT_OUTFILE;
276 prefix return OPT_PREFIX;
277 yyclass return OPT_YYCLASS;
221
278
222<SECT2PROLOG>^{NOT_WS}.* { /* non-indented code */
279 \"[^"\n]*\" {
280 strcpy( nmstr, yytext + 1 );
281 nmstr[strlen( nmstr ) - 1] = '\0';
282 return NAME;
283 }
284
285 (([a-mo-z]|n[a-np-z])[[:alpha:]\-+]*)|. {
286 format_synerr( _( "unrecognized %%option: %s" ),
287 yytext );
288 BEGIN(RECOVER);
289 }
290}
291
292<RECOVER>.*{NL} ++linenum; BEGIN(INITIAL);
293
294
295<SECT2PROLOG>{
296 ^"%{".* ++bracelevel; yyless( 2 ); /* eat only %{ */
297 ^"%}".* --bracelevel; yyless( 2 ); /* eat only %} */
298
299 ^{WS}.* ACTION_ECHO; /* indented code in prolog */
300
301 ^{NOT_WS}.* { /* non-indented code */
223 if ( bracelevel <= 0 )
224 { /* not in %{ ... %} */
225 yyless( 0 ); /* put it all back */
302 if ( bracelevel <= 0 )
303 { /* not in %{ ... %} */
304 yyless( 0 ); /* put it all back */
305 yy_set_bol( 1 );
226 mark_prolog();
227 BEGIN(SECT2);
228 }
229 else
230 ACTION_ECHO;
231 }
232
306 mark_prolog();
307 BEGIN(SECT2);
308 }
309 else
310 ACTION_ECHO;
311 }
312
233<SECT2PROLOG>.* ACTION_ECHO;
234<SECT2PROLOG>{NL} ++linenum; ACTION_ECHO;
313 .* ACTION_ECHO;
314 {NL} ++linenum; ACTION_ECHO;
235
315
236<SECT2PROLOG><<EOF>> {
316 <<EOF>> {
237 mark_prolog();
238 sectnum = 0;
239 yyterminate(); /* to stop the parser */
240 }
317 mark_prolog();
318 sectnum = 0;
319 yyterminate(); /* to stop the parser */
320 }
321}
241
322
242<SECT2>^{OPTWS}{NL} ++linenum; /* allow blank lines in section 2 */
323<SECT2>{
324 ^{OPTWS}{NL} ++linenum; /* allow blank lines in section 2 */
243
325
244<SECT2>^({WS}|"%{") {
245 indented_code = (yytext[0] != '%');
326 ^{OPTWS}"%{" {
327 indented_code = false;
246 doing_codeblock = true;
247 bracelevel = 1;
328 doing_codeblock = true;
329 bracelevel = 1;
248
249 if ( indented_code )
250 ACTION_ECHO;
251
252 BEGIN(CODEBLOCK_2);
330 BEGIN(PERCENT_BRACE_ACTION);
253 }
254
331 }
332
255<SECT2>^"<" BEGIN(SC); return '<';
256<SECT2>^"^" return '^';
257<SECT2>\" BEGIN(QUOTE); return '"';
258<SECT2>"{"/[0-9] BEGIN(NUM); return '{';
259<SECT2>"{"[^0-9\n][^}\n]* BEGIN(BRACEERROR);
260<SECT2>"$"/([ \t]|{NL}) return '$';
333 ^{OPTWS}"<" BEGIN(SC); return '<';
334 ^{OPTWS}"^" return '^';
335 \" BEGIN(QUOTE); return '"';
336 "{"/[[:digit:]] BEGIN(NUM); return '{';
337 "$"/([[:blank:]]|{NL}) return '$';
261
338
262<SECT2>{WS}"%{" {
339 {WS}"%{" {
263 bracelevel = 1;
264 BEGIN(PERCENT_BRACE_ACTION);
340 bracelevel = 1;
341 BEGIN(PERCENT_BRACE_ACTION);
265 return '\n';
342
343 if ( in_rule )
344 {
345 doing_rule_action = true;
346 in_rule = false;
347 return '\n';
348 }
266 }
349 }
267<SECT2>{WS}"|".*{NL} continued_action = true; ++linenum; return '\n';
350 {WS}"|".*{NL} continued_action = true; ++linenum; return '\n';
268
351
269<SECT2>{WS} {
352 ^{WS}"/*" {
353 yyless( yyleng - 2 ); /* put back '/', '*' */
354 bracelevel = 0;
355 continued_action = false;
356 BEGIN(ACTION);
357 }
358
359 ^{WS} /* allow indented rules */
360
361 {WS} {
270 /* This rule is separate from the one below because
271 * otherwise we get variable trailing context, so
272 * we can't build the scanner using -{f,F}.
273 */
274 bracelevel = 0;
275 continued_action = false;
276 BEGIN(ACTION);
362 /* This rule is separate from the one below because
363 * otherwise we get variable trailing context, so
364 * we can't build the scanner using -{f,F}.
365 */
366 bracelevel = 0;
367 continued_action = false;
368 BEGIN(ACTION);
277 return '\n';
369
370 if ( in_rule )
371 {
372 doing_rule_action = true;
373 in_rule = false;
374 return '\n';
375 }
278 }
279
376 }
377
280<SECT2>{OPTWS}{NL} {
378 {OPTWS}{NL} {
281 bracelevel = 0;
282 continued_action = false;
283 BEGIN(ACTION);
284 unput( '\n' ); /* so <ACTION> sees it */
379 bracelevel = 0;
380 continued_action = false;
381 BEGIN(ACTION);
382 unput( '\n' ); /* so <ACTION> sees it */
285 return '\n';
383
384 if ( in_rule )
385 {
386 doing_rule_action = true;
387 in_rule = false;
388 return '\n';
389 }
286 }
287
390 }
391
288<SECT2>"<<EOF>>" return EOF_OP;
392 ^{OPTWS}"<<EOF>>" |
393 "<<EOF>>" return EOF_OP;
289
394
290<SECT2>^"%%".* {
395 ^"%%".* {
291 sectnum = 3;
292 BEGIN(SECT3);
293 yyterminate(); /* to stop the parser */
294 }
295
396 sectnum = 3;
397 BEGIN(SECT3);
398 yyterminate(); /* to stop the parser */
399 }
400
296<SECT2>"["{FIRST_CCL_CHAR}{CCL_CHAR}* {
401 "["({FIRST_CCL_CHAR}|{CCL_EXPR})({CCL_CHAR}|{CCL_EXPR})* {
297 int cclval;
298
299 strcpy( nmstr, yytext );
300
301 /* Check to see if we've already encountered this
302 * ccl.
303 */
402 int cclval;
403
404 strcpy( nmstr, yytext );
405
406 /* Check to see if we've already encountered this
407 * ccl.
408 */
304 if ( (cclval = ccllookup( (Char *) nmstr )) )
409 if ( (cclval = ccllookup( (Char *) nmstr )) != 0 )
305 {
306 if ( input() != ']' )
410 {
411 if ( input() != ']' )
307 synerr( "bad character class" );
412 synerr( _( "bad character class" ) );
308
309 yylval = cclval;
310 ++cclreuse;
311 return PREVCCL;
312 }
313 else
314 {
315 /* We fudge a bit. We know that this ccl will

--- 6 unchanged lines hidden (view full) ---

322 */
323 yyless( 1 );
324
325 BEGIN(FIRSTCCL);
326 return '[';
327 }
328 }
329
413
414 yylval = cclval;
415 ++cclreuse;
416 return PREVCCL;
417 }
418 else
419 {
420 /* We fudge a bit. We know that this ccl will

--- 6 unchanged lines hidden (view full) ---

427 */
428 yyless( 1 );
429
430 BEGIN(FIRSTCCL);
431 return '[';
432 }
433 }
434
330<SECT2>"{"{NAME}"}" {
435 "{"{NAME}"}" {
331 register Char *nmdefptr;
332 Char *ndlookup();
333
334 strcpy( nmstr, yytext + 1 );
335 nmstr[yyleng - 2] = '\0'; /* chop trailing brace */
336
436 register Char *nmdefptr;
437 Char *ndlookup();
438
439 strcpy( nmstr, yytext + 1 );
440 nmstr[yyleng - 2] = '\0'; /* chop trailing brace */
441
337 if ( ! (nmdefptr = ndlookup( nmstr )) )
338 format_synerr( "undefined definition {%s}",
442 if ( (nmdefptr = ndlookup( nmstr )) == 0 )
443 format_synerr(
444 _( "undefined definition {%s}" ),
339 nmstr );
340
341 else
342 { /* push back name surrounded by ()'s */
343 int len = strlen( (char *) nmdefptr );
344
345 if ( lex_compat || nmdefptr[0] == '^' ||
346 (len > 0 && nmdefptr[len - 1] == '$') )

--- 8 unchanged lines hidden (view full) ---

355 {
356 unput(')');
357 PUT_BACK_STRING((char *) nmdefptr, 0);
358 unput('(');
359 }
360 }
361 }
362
445 nmstr );
446
447 else
448 { /* push back name surrounded by ()'s */
449 int len = strlen( (char *) nmdefptr );
450
451 if ( lex_compat || nmdefptr[0] == '^' ||
452 (len > 0 && nmdefptr[len - 1] == '$') )

--- 8 unchanged lines hidden (view full) ---

461 {
462 unput(')');
463 PUT_BACK_STRING((char *) nmdefptr, 0);
464 unput('(');
465 }
466 }
467 }
468
363<SECT2>[/|*+?.()] return (unsigned char) yytext[0];
364<SECT2>. RETURNCHAR;
469 [/|*+?.(){}] return (unsigned char) yytext[0];
470 . RETURNCHAR;
471}
365
366
472
473
367<SC>[,*] return (unsigned char) yytext[0];
368<SC>">" BEGIN(SECT2); return '>';
369<SC>">"/^ BEGIN(CARETISBOL); return '>';
370<SC>{SCNAME} RETURNNAME;
371<SC>. {
372 format_synerr( "bad <start condition>: %s", yytext );
474<SC>{
475 [,*] return (unsigned char) yytext[0];
476 ">" BEGIN(SECT2); return '>';
477 ">"/^ BEGIN(CARETISBOL); return '>';
478 {SCNAME} RETURNNAME;
479 . {
480 format_synerr( _( "bad <start condition>: %s" ),
481 yytext );
373 }
482 }
483}
374
375<CARETISBOL>"^" BEGIN(SECT2); return '^';
376
377
484
485<CARETISBOL>"^" BEGIN(SECT2); return '^';
486
487
378<QUOTE>[^"\n] RETURNCHAR;
379<QUOTE>\" BEGIN(SECT2); return '"';
488<QUOTE>{
489 [^"\n] RETURNCHAR;
490 \" BEGIN(SECT2); return '"';
380
491
381<QUOTE>{NL} {
382 synerr( "missing quote" );
492 {NL} {
493 synerr( _( "missing quote" ) );
383 BEGIN(SECT2);
384 ++linenum;
385 return '"';
386 }
494 BEGIN(SECT2);
495 ++linenum;
496 return '"';
497 }
498}
387
388
499
500
389<FIRSTCCL>"^"/[^-\]\n] BEGIN(CCL); return '^';
390<FIRSTCCL>"^"/("-"|"]") return '^';
391<FIRSTCCL>. BEGIN(CCL); RETURNCHAR;
501<FIRSTCCL>{
502 "^"/[^-\]\n] BEGIN(CCL); return '^';
503 "^"/("-"|"]") return '^';
504 . BEGIN(CCL); RETURNCHAR;
505}
392
506
393<CCL>-/[^\]\n] return '-';
394<CCL>[^\]\n] RETURNCHAR;
395<CCL>"]" BEGIN(SECT2); return ']';
396<CCL>.|{NL} {
397 synerr( "bad character class" );
507<CCL>{
508 -/[^\]\n] return '-';
509 [^\]\n] RETURNCHAR;
510 "]" BEGIN(SECT2); return ']';
511 .|{NL} {
512 synerr( _( "bad character class" ) );
398 BEGIN(SECT2);
399 return ']';
400 }
513 BEGIN(SECT2);
514 return ']';
515 }
516}
401
517
518<FIRSTCCL,CCL>{
519 "[:alnum:]" BEGIN(CCL); return CCE_ALNUM;
520 "[:alpha:]" BEGIN(CCL); return CCE_ALPHA;
521 "[:blank:]" BEGIN(CCL); return CCE_BLANK;
522 "[:cntrl:]" BEGIN(CCL); return CCE_CNTRL;
523 "[:digit:]" BEGIN(CCL); return CCE_DIGIT;
524 "[:graph:]" BEGIN(CCL); return CCE_GRAPH;
525 "[:lower:]" BEGIN(CCL); return CCE_LOWER;
526 "[:print:]" BEGIN(CCL); return CCE_PRINT;
527 "[:punct:]" BEGIN(CCL); return CCE_PUNCT;
528 "[:space:]" BEGIN(CCL); return CCE_SPACE;
529 "[:upper:]" BEGIN(CCL); return CCE_UPPER;
530 "[:xdigit:]" BEGIN(CCL); return CCE_XDIGIT;
531 {CCL_EXPR} {
532 format_synerr(
533 _( "bad character class expression: %s" ),
534 yytext );
535 BEGIN(CCL); return CCE_ALNUM;
536 }
537}
402
538
403<NUM>[0-9]+ {
539{
540 [[:digit:]]+ {
404 yylval = myctoi( yytext );
405 return NUMBER;
406 }
407
541 yylval = myctoi( yytext );
542 return NUMBER;
543 }
544
408<NUM>"," return ',';
409<NUM>"}" BEGIN(SECT2); return '}';
545 "," return ',';
546 "}" BEGIN(SECT2); return '}';
410
547
411<NUM>. {
412 synerr( "bad character inside {}'s" );
548 . {
549 synerr( _( "bad character inside {}'s" ) );
413 BEGIN(SECT2);
414 return '}';
415 }
416
550 BEGIN(SECT2);
551 return '}';
552 }
553
417<NUM>{NL} {
418 synerr( "missing }" );
554 {NL} {
555 synerr( _( "missing }" ) );
419 BEGIN(SECT2);
420 ++linenum;
421 return '}';
422 }
556 BEGIN(SECT2);
557 ++linenum;
558 return '}';
559 }
560}
423
424
561
562
425<BRACEERROR>"}" synerr( "bad name in {}'s" ); BEGIN(SECT2);
426<BRACEERROR>{NL} synerr( "missing }" ); ++linenum; BEGIN(SECT2);
563<PERCENT_BRACE_ACTION>{
564 {OPTWS}"%}".* bracelevel = 0;
427
565
566 <ACTION>"/*" ACTION_ECHO; yy_push_state( COMMENT );
428
567
429<CODEBLOCK_2>"/*" ACTION_ECHO; BEGIN(ACTION_COMMENT);
430<PERCENT_BRACE_ACTION,CODEBLOCK_2>{OPTWS}"%}".* bracelevel = 0;
431<PERCENT_BRACE_ACTION,CODEBLOCK_2,ACTION>"reject" {
568 <CODEBLOCK,ACTION>{
569 "reject" {
432 ACTION_ECHO;
433 CHECK_REJECT(yytext);
434 }
570 ACTION_ECHO;
571 CHECK_REJECT(yytext);
572 }
435<PERCENT_BRACE_ACTION,CODEBLOCK_2,ACTION>"yymore" {
573 "yymore" {
436 ACTION_ECHO;
437 CHECK_YYMORE(yytext);
438 }
574 ACTION_ECHO;
575 CHECK_YYMORE(yytext);
576 }
439<PERCENT_BRACE_ACTION,CODEBLOCK_2>{NAME}|{NOT_NAME}|. ACTION_ECHO;
440<PERCENT_BRACE_ACTION,CODEBLOCK_2>{NL} {
577 }
578
579 {NAME}|{NOT_NAME}|. ACTION_ECHO;
580 {NL} {
441 ++linenum;
442 ACTION_ECHO;
443 if ( bracelevel == 0 ||
444 (doing_codeblock && indented_code) )
445 {
581 ++linenum;
582 ACTION_ECHO;
583 if ( bracelevel == 0 ||
584 (doing_codeblock && indented_code) )
585 {
446 if ( ! doing_codeblock )
586 if ( doing_rule_action )
447 add_action( "\tYY_BREAK\n" );
587 add_action( "\tYY_BREAK\n" );
448
449 doing_codeblock = false;
588
589 doing_rule_action = doing_codeblock = false;
450 BEGIN(SECT2);
451 }
452 }
590 BEGIN(SECT2);
591 }
592 }
593}
453
454
455 /* Reject and YYmore() are checked for above, in PERCENT_BRACE_ACTION */
594
595
596 /* Reject and YYmore() are checked for above, in PERCENT_BRACE_ACTION */
456<ACTION>"{" ACTION_ECHO; ++bracelevel;
457<ACTION>"}" ACTION_ECHO; --bracelevel;
458<ACTION>[^a-z_{}"'/\n]+ ACTION_ECHO;
459<ACTION>{NAME} ACTION_ECHO;
460<ACTION>"/*" ACTION_ECHO; BEGIN(ACTION_COMMENT);
461<ACTION>"'"([^'\\\n]|\\.)*"'" ACTION_ECHO; /* character constant */
462<ACTION>\" ACTION_ECHO; BEGIN(ACTION_STRING);
463<ACTION>{NL} {
597<ACTION>{
598 "{" ACTION_ECHO; ++bracelevel;
599 "}" ACTION_ECHO; --bracelevel;
600 [^[:alpha:]_{}"'/\n]+ ACTION_ECHO;
601 {NAME} ACTION_ECHO;
602 "'"([^'\\\n]|\\.)*"'" ACTION_ECHO; /* character constant */
603 \" ACTION_ECHO; BEGIN(ACTION_STRING);
604 {NL} {
464 ++linenum;
465 ACTION_ECHO;
466 if ( bracelevel == 0 )
467 {
605 ++linenum;
606 ACTION_ECHO;
607 if ( bracelevel == 0 )
608 {
468 add_action( "\tYY_BREAK\n" );
609 if ( doing_rule_action )
610 add_action( "\tYY_BREAK\n" );
611
612 doing_rule_action = false;
469 BEGIN(SECT2);
470 }
471 }
613 BEGIN(SECT2);
614 }
615 }
472<ACTION>. ACTION_ECHO;
616 . ACTION_ECHO;
617}
473
618
474<ACTION_COMMENT>"*/" {
475 ACTION_ECHO;
476 if ( doing_codeblock )
477 BEGIN(CODEBLOCK_2);
478 else
479 BEGIN(ACTION);
480 }
619<ACTION_STRING>{
620 [^"\\\n]+ ACTION_ECHO;
621 \\. ACTION_ECHO;
622 {NL} ++linenum; ACTION_ECHO;
623 \" ACTION_ECHO; BEGIN(ACTION);
624 . ACTION_ECHO;
625}
481
626
482<ACTION_COMMENT>"*" ACTION_ECHO;
483<ACTION_COMMENT>[^*\n]+ ACTION_ECHO;
484<ACTION_COMMENT>[^*\n]*{NL} ++linenum; ACTION_ECHO;
485
486<ACTION_STRING>[^"\\\n]+ ACTION_ECHO;
487<ACTION_STRING>\\. ACTION_ECHO;
488<ACTION_STRING>{NL} ++linenum; ACTION_ECHO;
489<ACTION_STRING>\" ACTION_ECHO; BEGIN(ACTION);
490<ACTION_STRING>. ACTION_ECHO;
491
492<ACTION,ACTION_COMMENT,ACTION_STRING><<EOF>> {
493 synerr( "EOF encountered inside an action" );
627<COMMENT,ACTION,ACTION_STRING><<EOF>> {
628 synerr( _( "EOF encountered inside an action" ) );
494 yyterminate();
495 }
496
497
629 yyterminate();
630 }
631
632
498{ESCSEQ} {
633<SECT2,QUOTE,FIRSTCCL,CCL>{ESCSEQ} {
499 yylval = myesc( (Char *) yytext );
634 yylval = myesc( (Char *) yytext );
500 return CHAR;
501 }
502
635
503<FIRSTCCL>{ESCSEQ} {
504 yylval = myesc( (Char *) yytext );
505 BEGIN(CCL);
636 if ( YY_START == FIRSTCCL )
637 BEGIN(CCL);
638
506 return CHAR;
507 }
508
509
639 return CHAR;
640 }
641
642
510<SECT3>.*(\n?) ECHO;
511<SECT3><<EOF>> sectnum = 0; yyterminate();
643<SECT3>{
644 .*(\n?) ECHO;
645 <<EOF>> sectnum = 0; yyterminate();
646}
512
647
513<*>.|\n format_synerr( "bad character: %s", yytext );
648<*>.|\n format_synerr( _( "bad character: %s" ), yytext );
514
515%%
516
517
518int yywrap()
519 {
520 if ( --num_input_files > 0 )
521 {

--- 6 unchanged lines hidden (view full) ---

528 }
529
530
531/* set_input_file - open the given file (if NULL, stdin) for scanning */
532
533void set_input_file( file )
534char *file;
535 {
649
650%%
651
652
653int yywrap()
654 {
655 if ( --num_input_files > 0 )
656 {

--- 6 unchanged lines hidden (view full) ---

663 }
664
665
666/* set_input_file - open the given file (if NULL, stdin) for scanning */
667
668void set_input_file( file )
669char *file;
670 {
536 if ( file )
671 if ( file && strcmp( file, "-" ) )
537 {
672 {
538 infilename = file;
673 infilename = copy_string( file );
539 yyin = fopen( infilename, "r" );
540
541 if ( yyin == NULL )
674 yyin = fopen( infilename, "r" );
675
676 if ( yyin == NULL )
542 lerrsf( "can't open %s", file );
677 lerrsf( _( "can't open %s" ), file );
543 }
544
545 else
546 {
547 yyin = stdin;
678 }
679
680 else
681 {
682 yyin = stdin;
548 infilename = "<stdin>";
683 infilename = copy_string( "<stdin>" );
549 }
684 }
685
686 linenum = 1;
550 }
551
552
553/* Wrapper routines for accessing the scanner's malloc routines. */
554
555void *flex_alloc( size )
687 }
688
689
690/* Wrapper routines for accessing the scanner's malloc routines. */
691
692void *flex_alloc( size )
556unsigned int size;
693size_t size;
557 {
694 {
558 return yy_flex_alloc( size );
695 return (void *) malloc( size );
559 }
560
561void *flex_realloc( ptr, size )
562void *ptr;
696 }
697
698void *flex_realloc( ptr, size )
699void *ptr;
563unsigned int size;
700size_t size;
564 {
701 {
565 return yy_flex_realloc( ptr, size );
702 return (void *) realloc( ptr, size );
566 }
567
568void flex_free( ptr )
569void *ptr;
570 {
703 }
704
705void flex_free( ptr )
706void *ptr;
707 {
571 yy_flex_free( ptr );
708 if ( ptr )
709 free( ptr );
572 }
710 }