35 |
#define YY_LINES LOCATION_LINES (*yylloc, yyleng); lineno += yyleng; |
#define YY_LINES LOCATION_LINES (*yylloc, yyleng); lineno += yyleng; |
36 |
#define YY_STEP LOCATION_STEP (*yylloc) |
#define YY_STEP LOCATION_STEP (*yylloc) |
37 |
|
|
38 |
/* Appending to the STRING_OBSTACK. */ |
|
39 |
#define YY_INIT obstack_init (&string_obstack) |
/* STRING_OBSTACK -- Used to store all the characters that we need to |
40 |
#define YY_GROW obstack_grow (&string_obstack, yytext, yyleng) |
keep (to construct ID, STRINGS etc.). Use the following macros to |
41 |
#define YY_FINISH obstack_1grow (&string_obstack, '\0'); yylval->string = obstack_finish (&string_obstack); |
use it. |
42 |
|
|
43 |
|
Use YY_OBS_INIT to initialize a new growing string, YY_OBS_GROW to |
44 |
|
append what has just been matched, and YY_OBS_FINISH to end the |
45 |
|
string (it puts the ending 0). YY_OBS_FINISH also stores this |
46 |
|
string in LAST_STRING, which can be used, and which is used by |
47 |
|
YY_OBS_FREE to free the last string. */ |
48 |
|
|
49 |
|
static struct obstack string_obstack; |
50 |
|
char *last_string; |
51 |
|
|
52 |
|
#define YY_OBS_INIT \ |
53 |
|
obstack_init (&string_obstack) |
54 |
|
|
55 |
|
#define YY_OBS_GROW \ |
56 |
|
obstack_grow (&string_obstack, yytext, yyleng) |
57 |
|
|
58 |
|
#define YY_OBS_FINISH \ |
59 |
|
do { \ |
60 |
|
obstack_1grow (&string_obstack, '\0'); \ |
61 |
|
last_string = obstack_finish (&string_obstack); \ |
62 |
|
yylval->string = last_string; \ |
63 |
|
} while (0) |
64 |
|
|
65 |
|
#define YY_OBS_FREE \ |
66 |
|
do { \ |
67 |
|
obstack_free (&string_obstack, last_string); \ |
68 |
|
} while (0) |
69 |
|
|
70 |
/* This is only to avoid GCC warnings. */ |
/* This is only to avoid GCC warnings. */ |
71 |
#define YY_USER_INIT if (yycontrol) {;}; |
#define YY_USER_INIT if (yycontrol) {;}; |
72 |
|
|
73 |
static struct obstack string_obstack; |
|
74 |
static int braces_level = 0; |
static int braces_level = 0; |
75 |
static int percent_percent_count = 0; |
static int percent_percent_count = 0; |
76 |
|
|
148 |
{eols} YY_LINES; YY_STEP; |
{eols} YY_LINES; YY_STEP; |
149 |
{blanks} YY_STEP; |
{blanks} YY_STEP; |
150 |
{id} { |
{id} { |
151 |
YY_INIT; YY_GROW; YY_FINISH; |
YY_OBS_INIT; YY_OBS_GROW; YY_OBS_FINISH; |
152 |
yylval->symbol = getsym (yylval->string); |
yylval->symbol = getsym (last_string); |
153 |
|
YY_OBS_FREE; |
154 |
return ID; |
return ID; |
155 |
} |
} |
156 |
|
|
157 |
{int} yylval->integer = strtol (yytext, 0, 10); return INT; |
{int} yylval->integer = strtol (yytext, 0, 10); return INT; |
158 |
|
|
159 |
/* Characters. We don't check there is only one. */ |
/* Characters. We don't check there is only one. */ |
160 |
\' YY_INIT; YY_GROW; yy_push_state (SC_ESCAPED_CHARACTER); |
\' YY_OBS_INIT; YY_OBS_GROW; yy_push_state (SC_ESCAPED_CHARACTER); |
161 |
|
|
162 |
/* Strings. */ |
/* Strings. */ |
163 |
\" YY_INIT; YY_GROW; yy_push_state (SC_ESCAPED_STRING); |
\" YY_OBS_INIT; YY_OBS_GROW; yy_push_state (SC_ESCAPED_STRING); |
164 |
|
|
165 |
/* Comments. */ |
/* Comments. */ |
166 |
"/*" yy_push_state (SC_COMMENT); |
"/*" yy_push_state (SC_COMMENT); |
167 |
"//".* YY_STEP; |
"//".* YY_STEP; |
168 |
|
|
169 |
/* Prologue. */ |
/* Prologue. */ |
170 |
"%{" YY_INIT; yy_push_state (SC_PROLOGUE); |
"%{" YY_OBS_INIT; yy_push_state (SC_PROLOGUE); |
171 |
|
|
172 |
/* Code in between braces. */ |
/* Code in between braces. */ |
173 |
"{" YY_INIT; YY_GROW; ++braces_level; yy_push_state (SC_BRACED_CODE); |
"{" YY_OBS_INIT; YY_OBS_GROW; ++braces_level; yy_push_state (SC_BRACED_CODE); |
174 |
|
|
175 |
/* A type. */ |
/* A type. */ |
176 |
"<"[^>]+">" YY_INIT; obstack_grow (&string_obstack, yytext + 1, yyleng - 2); YY_FINISH; return TYPE; |
"<"[^>]+">" YY_OBS_INIT; obstack_grow (&string_obstack, yytext + 1, yyleng - 2); YY_OBS_FINISH; return TYPE; |
177 |
|
|
178 |
"%%" { |
"%%" { |
179 |
if (++percent_percent_count == 2) |
if (++percent_percent_count == 2) |
216 |
} |
} |
217 |
else |
else |
218 |
{ |
{ |
219 |
YY_GROW; |
YY_OBS_GROW; |
220 |
} |
} |
221 |
yy_pop_state (); |
yy_pop_state (); |
222 |
} |
} |
223 |
|
|
224 |
[^\[\]*\n\r]+ if (yy_top_state () != INITIAL) YY_GROW; |
[^\[\]*\n\r]+ if (yy_top_state () != INITIAL) YY_OBS_GROW; |
225 |
{eols} if (yy_top_state () != INITIAL) YY_GROW; YY_LINES; |
{eols} if (yy_top_state () != INITIAL) YY_OBS_GROW; YY_LINES; |
226 |
. /* Stray `*'. */if (yy_top_state () != INITIAL) YY_GROW; |
. /* Stray `*'. */if (yy_top_state () != INITIAL) YY_OBS_GROW; |
227 |
|
|
228 |
<<EOF>> { |
<<EOF>> { |
229 |
LOCATION_PRINT (stderr, *yylloc); |
LOCATION_PRINT (stderr, *yylloc); |
242 |
{ |
{ |
243 |
\" { |
\" { |
244 |
assert (yy_top_state () == INITIAL); |
assert (yy_top_state () == INITIAL); |
245 |
YY_GROW; |
YY_OBS_GROW; |
246 |
YY_FINISH; |
YY_OBS_FINISH; |
247 |
yy_pop_state (); |
yy_pop_state (); |
248 |
return STRING; |
return STRING; |
249 |
} |
} |
250 |
|
|
251 |
[^\"\n\r\\]+ YY_GROW; |
[^\"\n\r\\]+ YY_OBS_GROW; |
252 |
|
|
253 |
{eols} obstack_1grow (&string_obstack, '\n'); YY_LINES; |
{eols} obstack_1grow (&string_obstack, '\n'); YY_LINES; |
254 |
|
|
256 |
LOCATION_PRINT (stderr, *yylloc); |
LOCATION_PRINT (stderr, *yylloc); |
257 |
fprintf (stderr, ": unexpected end of file in a string\n"); |
fprintf (stderr, ": unexpected end of file in a string\n"); |
258 |
assert (yy_top_state () == INITIAL); |
assert (yy_top_state () == INITIAL); |
259 |
YY_FINISH; |
YY_OBS_FINISH; |
260 |
yy_pop_state (); |
yy_pop_state (); |
261 |
return STRING; |
return STRING; |
262 |
} |
} |
270 |
<SC_ESCAPED_CHARACTER> |
<SC_ESCAPED_CHARACTER> |
271 |
{ |
{ |
272 |
\' { |
\' { |
273 |
YY_GROW; |
YY_OBS_GROW; |
274 |
assert (yy_top_state () == INITIAL); |
assert (yy_top_state () == INITIAL); |
275 |
{ |
{ |
276 |
char c; |
YY_OBS_FINISH; |
277 |
YY_FINISH; |
yylval->symbol = getsym (last_string); |
|
c = yylval->string[1]; |
|
|
yylval->symbol = getsym (yylval->string); |
|
278 |
symbol_class_set (yylval->symbol, token_sym); |
symbol_class_set (yylval->symbol, token_sym); |
279 |
symbol_user_token_number_set (yylval->symbol, (unsigned int) c); |
symbol_user_token_number_set (yylval->symbol, last_string[1]); |
280 |
|
YY_OBS_FREE; |
281 |
yy_pop_state (); |
yy_pop_state (); |
282 |
return ID; |
return ID; |
283 |
} |
} |
284 |
} |
} |
285 |
|
|
286 |
[^\'\n\r\\] YY_GROW; |
[^\'\n\r\\] YY_OBS_GROW; |
287 |
|
|
288 |
{eols} obstack_1grow (&string_obstack, '\n'); YY_LINES; |
{eols} obstack_1grow (&string_obstack, '\n'); YY_LINES; |
289 |
|
|
291 |
LOCATION_PRINT (stderr, *yylloc); |
LOCATION_PRINT (stderr, *yylloc); |
292 |
fprintf (stderr, ": unexpected end of file in a character\n"); |
fprintf (stderr, ": unexpected end of file in a character\n"); |
293 |
assert (yy_top_state () == INITIAL); |
assert (yy_top_state () == INITIAL); |
294 |
YY_FINISH; |
YY_OBS_FINISH; |
295 |
yy_pop_state (); |
yy_pop_state (); |
296 |
return CHARACTER; |
return CHARACTER; |
297 |
} |
} |
331 |
\\. { |
\\. { |
332 |
LOCATION_PRINT (stderr, *yylloc); |
LOCATION_PRINT (stderr, *yylloc); |
333 |
fprintf (stderr, ": unrecognized escape: %s\n", yytext); |
fprintf (stderr, ": unrecognized escape: %s\n", yytext); |
334 |
YY_GROW; |
YY_OBS_GROW; |
335 |
} |
} |
336 |
} |
} |
337 |
|
|
344 |
<SC_CHARACTER> |
<SC_CHARACTER> |
345 |
{ |
{ |
346 |
\' { |
\' { |
347 |
YY_GROW; |
YY_OBS_GROW; |
348 |
assert (yy_top_state () != INITIAL); |
assert (yy_top_state () != INITIAL); |
349 |
yy_pop_state (); |
yy_pop_state (); |
350 |
} |
} |
351 |
|
|
352 |
[^\[\]\'\n\r\\] YY_GROW; |
[^\[\]\'\n\r\\] YY_OBS_GROW; |
353 |
\\. YY_GROW; |
\\. YY_OBS_GROW; |
354 |
|
|
355 |
{eols} YY_GROW; YY_LINES; |
{eols} YY_OBS_GROW; YY_LINES; |
356 |
|
|
357 |
<<EOF>> { |
<<EOF>> { |
358 |
LOCATION_PRINT (stderr, *yylloc); |
LOCATION_PRINT (stderr, *yylloc); |
372 |
{ |
{ |
373 |
\" { |
\" { |
374 |
assert (yy_top_state () != INITIAL); |
assert (yy_top_state () != INITIAL); |
375 |
YY_GROW; |
YY_OBS_GROW; |
376 |
yy_pop_state (); |
yy_pop_state (); |
377 |
} |
} |
378 |
|
|
379 |
[^\[\]\"\n\r\\]+ YY_GROW; |
[^\[\]\"\n\r\\]+ YY_OBS_GROW; |
380 |
\\. YY_GROW; |
\\. YY_OBS_GROW; |
381 |
|
|
382 |
{eols} YY_GROW; YY_LINES; |
{eols} YY_OBS_GROW; YY_LINES; |
383 |
|
|
384 |
<<EOF>> { |
<<EOF>> { |
385 |
LOCATION_PRINT (stderr, *yylloc); |
LOCATION_PRINT (stderr, *yylloc); |
397 |
<SC_BRACED_CODE,SC_PROLOGUE,SC_EPILOGUE> |
<SC_BRACED_CODE,SC_PROLOGUE,SC_EPILOGUE> |
398 |
{ |
{ |
399 |
/* Characters. We don't check there is only one. */ |
/* Characters. We don't check there is only one. */ |
400 |
\' YY_GROW; yy_push_state (SC_CHARACTER); |
\' YY_OBS_GROW; yy_push_state (SC_CHARACTER); |
401 |
|
|
402 |
/* Strings. */ |
/* Strings. */ |
403 |
\" YY_GROW; yy_push_state (SC_STRING); |
\" YY_OBS_GROW; yy_push_state (SC_STRING); |
404 |
|
|
405 |
/* Comments. */ |
/* Comments. */ |
406 |
"/*" YY_GROW; yy_push_state (SC_COMMENT); |
"/*" YY_OBS_GROW; yy_push_state (SC_COMMENT); |
407 |
"//".* YY_GROW; |
"//".* YY_OBS_GROW; |
408 |
} |
} |
409 |
|
|
410 |
|
|
416 |
<SC_BRACED_CODE> |
<SC_BRACED_CODE> |
417 |
{ |
{ |
418 |
"}" { |
"}" { |
419 |
YY_GROW; |
YY_OBS_GROW; |
420 |
if (--braces_level == 0) |
if (--braces_level == 0) |
421 |
{ |
{ |
422 |
yy_pop_state (); |
yy_pop_state (); |
423 |
YY_FINISH; |
YY_OBS_FINISH; |
424 |
return BRACED_CODE; |
return BRACED_CODE; |
425 |
} |
} |
426 |
} |
} |
427 |
|
|
428 |
"{" YY_GROW; braces_level++; |
"{" YY_OBS_GROW; braces_level++; |
429 |
|
|
430 |
"$"("<".*">")?(-?[0-9]+|"$") { handle_dollar (yytext); } |
"$"("<".*">")?(-?[0-9]+|"$") { handle_dollar (yytext); } |
431 |
"@"(-?[0-9]+|"$") { handle_at (yytext); } |
"@"(-?[0-9]+|"$") { handle_at (yytext); } |
432 |
|
|
433 |
[^\[\]$/\'\"@\{\}\n\r]+ YY_GROW; |
[^\[\]$/\'\"@\{\}\n\r]+ YY_OBS_GROW; |
434 |
{eols} YY_GROW; YY_LINES; |
{eols} YY_OBS_GROW; YY_LINES; |
435 |
|
|
436 |
/* A lose $, or /, or etc. */ |
/* A lose $, or /, or etc. */ |
437 |
. YY_GROW; |
. YY_OBS_GROW; |
438 |
|
|
439 |
<<EOF>> { |
<<EOF>> { |
440 |
LOCATION_PRINT (stderr, *yylloc); |
LOCATION_PRINT (stderr, *yylloc); |
441 |
fprintf (stderr, ": unexpected end of file in a braced code\n"); |
fprintf (stderr, ": unexpected end of file in a braced code\n"); |
442 |
yy_pop_state (); |
yy_pop_state (); |
443 |
YY_FINISH; |
YY_OBS_FINISH; |
444 |
return PROLOGUE; |
return PROLOGUE; |
445 |
} |
} |
446 |
|
|
455 |
{ |
{ |
456 |
"%}" { |
"%}" { |
457 |
yy_pop_state (); |
yy_pop_state (); |
458 |
YY_FINISH; |
YY_OBS_FINISH; |
459 |
return PROLOGUE; |
return PROLOGUE; |
460 |
} |
} |
461 |
|
|
462 |
[^\[\]%\n\r]+ YY_GROW; |
[^\[\]%\n\r]+ YY_OBS_GROW; |
463 |
"%"+[^%\}\n\r]+ YY_GROW; |
"%"+[^%\}\n\r]+ YY_OBS_GROW; |
464 |
{eols} YY_GROW; YY_LINES; |
{eols} YY_OBS_GROW; YY_LINES; |
465 |
|
|
466 |
<<EOF>> { |
<<EOF>> { |
467 |
LOCATION_PRINT (stderr, *yylloc); |
LOCATION_PRINT (stderr, *yylloc); |
468 |
fprintf (stderr, ": unexpected end of file in a prologue\n"); |
fprintf (stderr, ": unexpected end of file in a prologue\n"); |
469 |
yy_pop_state (); |
yy_pop_state (); |
470 |
YY_FINISH; |
YY_OBS_FINISH; |
471 |
return PROLOGUE; |
return PROLOGUE; |
472 |
} |
} |
473 |
|
|
481 |
|
|
482 |
<SC_EPILOGUE> |
<SC_EPILOGUE> |
483 |
{ |
{ |
484 |
([^\[\]]|{eols})+ YY_GROW; |
([^\[\]]|{eols})+ YY_OBS_GROW; |
485 |
|
|
486 |
<<EOF>> { |
<<EOF>> { |
487 |
yy_pop_state (); |
yy_pop_state (); |
488 |
YY_FINISH; |
YY_OBS_FINISH; |
489 |
return EPILOGUE; |
return EPILOGUE; |
490 |
} |
} |
491 |
} |
} |