* src/scan-gram.l (YY_INIT, YY_GROW, YY_FINISH): Rename as...

(YY_OBS_INIT, YY_OBS_GROW, YY_OBS_FINISH): these.
(last_string, YY_OBS_FREE): New.
Use them when returning an ID.
This commit is contained in:
Akim Demaille
2002-06-11 21:43:18 +00:00
parent e9955c8373
commit 44995b2e39
3 changed files with 307 additions and 229 deletions

View File

@@ -1,3 +1,10 @@
2002-06-11 Akim Demaille <akim@epita.fr>
* src/scan-gram.l (YY_INIT, YY_GROW, YY_FINISH): Rename as...
(YY_OBS_INIT, YY_OBS_GROW, YY_OBS_FINISH): these.
(last_string, YY_OBS_FREE): New.
Use them when returning an ID.
2002-06-11 Akim Demaille <akim@epita.fr> 2002-06-11 Akim Demaille <akim@epita.fr>
Have Bison grammars parsed by a Bison grammar. Have Bison grammars parsed by a Bison grammar.

View File

@@ -27,7 +27,7 @@
#define YY_FLEX_MINOR_VERSION 5 #define YY_FLEX_MINOR_VERSION 5
#include <stdio.h> #include <stdio.h>
#include <errno.h>
/* cfront 1.2 defines "c_plusplus" instead of "__cplusplus" */ /* cfront 1.2 defines "c_plusplus" instead of "__cplusplus" */
#ifdef c_plusplus #ifdef c_plusplus
@@ -40,7 +40,9 @@
#ifdef __cplusplus #ifdef __cplusplus
#include <stdlib.h> #include <stdlib.h>
#ifndef _WIN32
#include <unistd.h> #include <unistd.h>
#endif
/* Use prototypes in function declarations. */ /* Use prototypes in function declarations. */
#define YY_USE_PROTOS #define YY_USE_PROTOS
@@ -687,16 +689,16 @@ int yy_flex_debug = 1;
static yyconst short int yy_rule_linenum[92] = static yyconst short int yy_rule_linenum[92] =
{ 0, { 0,
88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124,
98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134,
108, 109, 110, 111, 112, 113, 114, 116, 117, 118, 135, 136, 137, 138, 139, 140, 141, 143, 144, 145,
119, 121, 122, 123, 129, 132, 135, 138, 139, 142, 146, 148, 149, 150, 157, 160, 163, 166, 167, 170,
145, 148, 150, 156, 172, 173, 184, 196, 197, 198, 173, 176, 178, 184, 200, 201, 212, 224, 225, 226,
215, 223, 225, 244, 259, 261, 280, 292, 296, 297, 243, 251, 253, 272, 286, 288, 307, 319, 323, 324,
298, 299, 300, 301, 302, 303, 304, 319, 325, 326, 325, 326, 327, 328, 329, 330, 331, 346, 352, 353,
328, 346, 352, 353, 355, 373, 376, 379, 380, 391, 355, 373, 379, 380, 382, 400, 403, 406, 407, 418,
401, 403, 404, 406, 407, 410, 429, 435, 436, 437, 428, 430, 431, 433, 434, 437, 456, 462, 463, 464,
457 484
} ; } ;
@@ -746,15 +748,42 @@ char *yytext;
#define YY_LINES LOCATION_LINES (*yylloc, yyleng); lineno += yyleng; #define YY_LINES LOCATION_LINES (*yylloc, yyleng); lineno += yyleng;
#define YY_STEP LOCATION_STEP (*yylloc) #define YY_STEP LOCATION_STEP (*yylloc)
/* Appending to the STRING_OBSTACK. */
#define YY_INIT obstack_init (&string_obstack) /* STRING_OBSTACK -- Used to store all the characters that we need to
#define YY_GROW obstack_grow (&string_obstack, yytext, yyleng) keep (to construct ID, STRINGS etc.). Use the following macros to
#define YY_FINISH obstack_1grow (&string_obstack, '\0'); yylval->string = obstack_finish (&string_obstack); use it.
Use YY_OBS_INIT to initialize a new growing string, YY_OBS_GROW to
append what has just been matched, and YY_OBS_FINISH to end the
string (it puts the ending 0). YY_OBS_FINISH also stores this
string in LAST_STRING, which can be used, and which is used by
YY_OBS_FREE to free the last string. */
static struct obstack string_obstack;
char *last_string;
#define YY_OBS_INIT \
obstack_init (&string_obstack)
#define YY_OBS_GROW \
obstack_grow (&string_obstack, yytext, yyleng)
#define YY_OBS_FINISH \
do { \
obstack_1grow (&string_obstack, '\0'); \
last_string = obstack_finish (&string_obstack); \
yylval->string = last_string; \
} while (0)
#define YY_OBS_FREE \
do { \
obstack_free (&string_obstack, last_string); \
} while (0)
/* This is only to avoid GCC warnings. */ /* This is only to avoid GCC warnings. */
#define YY_USER_INIT if (yycontrol) {;}; #define YY_USER_INIT if (yycontrol) {;};
static struct obstack string_obstack;
static int braces_level = 0; static int braces_level = 0;
static int percent_percent_count = 0; static int percent_percent_count = 0;
@@ -773,7 +802,7 @@ static void handle_at PARAMS ((char *cp));
#define SC_PROLOGUE 7 #define SC_PROLOGUE 7
#define SC_EPILOGUE 8 #define SC_EPILOGUE 8
#line 777 "scan-gram.c" #line 806 "scan-gram.c"
/* Macros after this point can all be overridden by user definitions in /* Macros after this point can all be overridden by user definitions in
* section 1. * section 1.
@@ -873,9 +902,20 @@ YY_MALLOC_DECL
YY_FATAL_ERROR( "input in flex scanner failed" ); \ YY_FATAL_ERROR( "input in flex scanner failed" ); \
result = n; \ result = n; \
} \ } \
else if ( ((result = fread( buf, 1, max_size, yyin )) == 0) \ else \
&& ferror( yyin ) ) \ { \
YY_FATAL_ERROR( "input in flex scanner failed" ); errno=0; \
while ( (result = fread(buf, 1, max_size, yyin))==0 && ferror(yyin)) \
{ \
if( errno != EINTR) \
{ \
YY_FATAL_ERROR( "input in flex scanner failed" ); \
break; \
} \
errno=0; \
clearerr(yyin); \
} \
}
#endif #endif
/* No semi-colon after return; correct usage is to write "yyterminate();" - /* No semi-colon after return; correct usage is to write "yyterminate();" -
@@ -924,7 +964,7 @@ YY_DECL
register char *yy_cp, *yy_bp; register char *yy_cp, *yy_bp;
register int yy_act; register int yy_act;
#line 64 "scan-gram.l" #line 91 "scan-gram.l"
/* At each yylex invocation, mark the current position as the /* At each yylex invocation, mark the current position as the
@@ -947,7 +987,7 @@ YY_DECL
/*----------------------------. /*----------------------------.
| Scanning Bison directives. | | Scanning Bison directives. |
`----------------------------*/ `----------------------------*/
#line 951 "scan-gram.c" #line 991 "scan-gram.c"
if ( yy_init ) if ( yy_init )
{ {
@@ -1049,227 +1089,228 @@ do_action: /* This label is used only to access EOF actions. */
case 1: case 1:
YY_RULE_SETUP YY_RULE_SETUP
#line 88 "scan-gram.l" #line 115 "scan-gram.l"
return PERCENT_NONASSOC; return PERCENT_NONASSOC;
YY_BREAK YY_BREAK
case 2: case 2:
YY_RULE_SETUP YY_RULE_SETUP
#line 89 "scan-gram.l" #line 116 "scan-gram.l"
return PERCENT_DEBUG; return PERCENT_DEBUG;
YY_BREAK YY_BREAK
case 3: case 3:
YY_RULE_SETUP YY_RULE_SETUP
#line 90 "scan-gram.l" #line 117 "scan-gram.l"
return PERCENT_DEFINE; return PERCENT_DEFINE;
YY_BREAK YY_BREAK
case 4: case 4:
YY_RULE_SETUP YY_RULE_SETUP
#line 91 "scan-gram.l" #line 118 "scan-gram.l"
return PERCENT_DEFINES; return PERCENT_DEFINES;
YY_BREAK YY_BREAK
case 5: case 5:
YY_RULE_SETUP YY_RULE_SETUP
#line 92 "scan-gram.l" #line 119 "scan-gram.l"
return PERCENT_ERROR_VERBOSE; return PERCENT_ERROR_VERBOSE;
YY_BREAK YY_BREAK
case 6: case 6:
YY_RULE_SETUP YY_RULE_SETUP
#line 93 "scan-gram.l" #line 120 "scan-gram.l"
return PERCENT_EXPECT; return PERCENT_EXPECT;
YY_BREAK YY_BREAK
case 7: case 7:
YY_RULE_SETUP YY_RULE_SETUP
#line 94 "scan-gram.l" #line 121 "scan-gram.l"
return PERCENT_FILE_PREFIX; return PERCENT_FILE_PREFIX;
YY_BREAK YY_BREAK
case 8: case 8:
YY_RULE_SETUP YY_RULE_SETUP
#line 95 "scan-gram.l" #line 122 "scan-gram.l"
return PERCENT_YACC; return PERCENT_YACC;
YY_BREAK YY_BREAK
case 9: case 9:
YY_RULE_SETUP YY_RULE_SETUP
#line 96 "scan-gram.l" #line 123 "scan-gram.l"
return PERCENT_LEFT; return PERCENT_LEFT;
YY_BREAK YY_BREAK
case 10: case 10:
YY_RULE_SETUP YY_RULE_SETUP
#line 97 "scan-gram.l" #line 124 "scan-gram.l"
return PERCENT_LOCATIONS; return PERCENT_LOCATIONS;
YY_BREAK YY_BREAK
case 11: case 11:
YY_RULE_SETUP YY_RULE_SETUP
#line 98 "scan-gram.l" #line 125 "scan-gram.l"
return PERCENT_NAME_PREFIX; return PERCENT_NAME_PREFIX;
YY_BREAK YY_BREAK
case 12: case 12:
YY_RULE_SETUP YY_RULE_SETUP
#line 99 "scan-gram.l" #line 126 "scan-gram.l"
return PERCENT_NO_LINES; return PERCENT_NO_LINES;
YY_BREAK YY_BREAK
case 13: case 13:
YY_RULE_SETUP YY_RULE_SETUP
#line 100 "scan-gram.l" #line 127 "scan-gram.l"
return PERCENT_NONASSOC; return PERCENT_NONASSOC;
YY_BREAK YY_BREAK
case 14: case 14:
YY_RULE_SETUP YY_RULE_SETUP
#line 101 "scan-gram.l" #line 128 "scan-gram.l"
return PERCENT_NTERM; return PERCENT_NTERM;
YY_BREAK YY_BREAK
case 15: case 15:
YY_RULE_SETUP YY_RULE_SETUP
#line 102 "scan-gram.l" #line 129 "scan-gram.l"
return PERCENT_OUTPUT; return PERCENT_OUTPUT;
YY_BREAK YY_BREAK
case 16: case 16:
YY_RULE_SETUP YY_RULE_SETUP
#line 103 "scan-gram.l" #line 130 "scan-gram.l"
return PERCENT_PREC; return PERCENT_PREC;
YY_BREAK YY_BREAK
case 17: case 17:
YY_RULE_SETUP YY_RULE_SETUP
#line 104 "scan-gram.l" #line 131 "scan-gram.l"
return PERCENT_PURE_PARSER; return PERCENT_PURE_PARSER;
YY_BREAK YY_BREAK
case 18: case 18:
YY_RULE_SETUP YY_RULE_SETUP
#line 105 "scan-gram.l" #line 132 "scan-gram.l"
return PERCENT_RIGHT; return PERCENT_RIGHT;
YY_BREAK YY_BREAK
case 19: case 19:
YY_RULE_SETUP YY_RULE_SETUP
#line 106 "scan-gram.l" #line 133 "scan-gram.l"
return PERCENT_SKELETON; return PERCENT_SKELETON;
YY_BREAK YY_BREAK
case 20: case 20:
YY_RULE_SETUP YY_RULE_SETUP
#line 107 "scan-gram.l" #line 134 "scan-gram.l"
return PERCENT_START; return PERCENT_START;
YY_BREAK YY_BREAK
case 21: case 21:
YY_RULE_SETUP YY_RULE_SETUP
#line 108 "scan-gram.l" #line 135 "scan-gram.l"
return PERCENT_TOKEN; return PERCENT_TOKEN;
YY_BREAK YY_BREAK
case 22: case 22:
YY_RULE_SETUP YY_RULE_SETUP
#line 109 "scan-gram.l" #line 136 "scan-gram.l"
return PERCENT_TOKEN; return PERCENT_TOKEN;
YY_BREAK YY_BREAK
case 23: case 23:
YY_RULE_SETUP YY_RULE_SETUP
#line 110 "scan-gram.l" #line 137 "scan-gram.l"
return PERCENT_TOKEN_TABLE; return PERCENT_TOKEN_TABLE;
YY_BREAK YY_BREAK
case 24: case 24:
YY_RULE_SETUP YY_RULE_SETUP
#line 111 "scan-gram.l" #line 138 "scan-gram.l"
return PERCENT_TYPE; return PERCENT_TYPE;
YY_BREAK YY_BREAK
case 25: case 25:
YY_RULE_SETUP YY_RULE_SETUP
#line 112 "scan-gram.l" #line 139 "scan-gram.l"
return PERCENT_UNION; return PERCENT_UNION;
YY_BREAK YY_BREAK
case 26: case 26:
YY_RULE_SETUP YY_RULE_SETUP
#line 113 "scan-gram.l" #line 140 "scan-gram.l"
return PERCENT_VERBOSE; return PERCENT_VERBOSE;
YY_BREAK YY_BREAK
case 27: case 27:
YY_RULE_SETUP YY_RULE_SETUP
#line 114 "scan-gram.l" #line 141 "scan-gram.l"
return PERCENT_YACC; return PERCENT_YACC;
YY_BREAK YY_BREAK
case 28: case 28:
YY_RULE_SETUP YY_RULE_SETUP
#line 116 "scan-gram.l" #line 143 "scan-gram.l"
return EQUAL; return EQUAL;
YY_BREAK YY_BREAK
case 29: case 29:
YY_RULE_SETUP YY_RULE_SETUP
#line 117 "scan-gram.l" #line 144 "scan-gram.l"
return COLON; return COLON;
YY_BREAK YY_BREAK
case 30: case 30:
YY_RULE_SETUP YY_RULE_SETUP
#line 118 "scan-gram.l" #line 145 "scan-gram.l"
return PIPE; return PIPE;
YY_BREAK YY_BREAK
case 31: case 31:
YY_RULE_SETUP YY_RULE_SETUP
#line 119 "scan-gram.l" #line 146 "scan-gram.l"
return SEMICOLON; return SEMICOLON;
YY_BREAK YY_BREAK
case 32: case 32:
YY_RULE_SETUP YY_RULE_SETUP
#line 121 "scan-gram.l" #line 148 "scan-gram.l"
YY_LINES; YY_STEP; YY_LINES; YY_STEP;
YY_BREAK YY_BREAK
case 33: case 33:
YY_RULE_SETUP YY_RULE_SETUP
#line 122 "scan-gram.l" #line 149 "scan-gram.l"
YY_STEP; YY_STEP;
YY_BREAK YY_BREAK
case 34: case 34:
YY_RULE_SETUP YY_RULE_SETUP
#line 123 "scan-gram.l" #line 150 "scan-gram.l"
{ {
YY_INIT; YY_GROW; YY_FINISH; YY_OBS_INIT; YY_OBS_GROW; YY_OBS_FINISH;
yylval->symbol = getsym (yylval->string); yylval->symbol = getsym (last_string);
YY_OBS_FREE;
return ID; return ID;
} }
YY_BREAK YY_BREAK
case 35: case 35:
YY_RULE_SETUP YY_RULE_SETUP
#line 129 "scan-gram.l" #line 157 "scan-gram.l"
yylval->integer = strtol (yytext, 0, 10); return INT; yylval->integer = strtol (yytext, 0, 10); return INT;
YY_BREAK YY_BREAK
/* Characters. We don't check there is only one. */ /* Characters. We don't check there is only one. */
case 36: case 36:
YY_RULE_SETUP YY_RULE_SETUP
#line 132 "scan-gram.l" #line 160 "scan-gram.l"
YY_INIT; YY_GROW; yy_push_state (SC_ESCAPED_CHARACTER); YY_OBS_INIT; YY_OBS_GROW; yy_push_state (SC_ESCAPED_CHARACTER);
YY_BREAK YY_BREAK
/* Strings. */ /* Strings. */
case 37: case 37:
YY_RULE_SETUP YY_RULE_SETUP
#line 135 "scan-gram.l" #line 163 "scan-gram.l"
YY_INIT; YY_GROW; yy_push_state (SC_ESCAPED_STRING); YY_OBS_INIT; YY_OBS_GROW; yy_push_state (SC_ESCAPED_STRING);
YY_BREAK YY_BREAK
/* Comments. */ /* Comments. */
case 38: case 38:
YY_RULE_SETUP YY_RULE_SETUP
#line 138 "scan-gram.l" #line 166 "scan-gram.l"
yy_push_state (SC_COMMENT); yy_push_state (SC_COMMENT);
YY_BREAK YY_BREAK
case 39: case 39:
YY_RULE_SETUP YY_RULE_SETUP
#line 139 "scan-gram.l" #line 167 "scan-gram.l"
YY_STEP; YY_STEP;
YY_BREAK YY_BREAK
/* Prologue. */ /* Prologue. */
case 40: case 40:
YY_RULE_SETUP YY_RULE_SETUP
#line 142 "scan-gram.l" #line 170 "scan-gram.l"
YY_INIT; yy_push_state (SC_PROLOGUE); YY_OBS_INIT; yy_push_state (SC_PROLOGUE);
YY_BREAK YY_BREAK
/* Code in between braces. */ /* Code in between braces. */
case 41: case 41:
YY_RULE_SETUP YY_RULE_SETUP
#line 145 "scan-gram.l" #line 173 "scan-gram.l"
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);
YY_BREAK YY_BREAK
/* A type. */ /* A type. */
case 42: case 42:
YY_RULE_SETUP YY_RULE_SETUP
#line 148 "scan-gram.l" #line 176 "scan-gram.l"
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;
YY_BREAK YY_BREAK
case 43: case 43:
YY_RULE_SETUP YY_RULE_SETUP
#line 150 "scan-gram.l" #line 178 "scan-gram.l"
{ {
if (++percent_percent_count == 2) if (++percent_percent_count == 2)
yy_push_state (SC_EPILOGUE); yy_push_state (SC_EPILOGUE);
@@ -1278,7 +1319,7 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 44: case 44:
YY_RULE_SETUP YY_RULE_SETUP
#line 156 "scan-gram.l" #line 184 "scan-gram.l"
{ {
LOCATION_PRINT (stderr, *yylloc); LOCATION_PRINT (stderr, *yylloc);
fprintf (stderr, ": invalid character: `%c'\n", *yytext); fprintf (stderr, ": invalid character: `%c'\n", *yytext);
@@ -1295,12 +1336,12 @@ YY_RULE_SETUP
case 45: case 45:
YY_RULE_SETUP YY_RULE_SETUP
#line 172 "scan-gram.l" #line 200 "scan-gram.l"
obstack_sgrow (&string_obstack, "@<:@"); obstack_sgrow (&string_obstack, "@<:@");
YY_BREAK YY_BREAK
case 46: case 46:
YY_RULE_SETUP YY_RULE_SETUP
#line 173 "scan-gram.l" #line 201 "scan-gram.l"
obstack_sgrow (&string_obstack, "@:>@"); obstack_sgrow (&string_obstack, "@:>@");
YY_BREAK YY_BREAK
@@ -1311,7 +1352,7 @@ obstack_sgrow (&string_obstack, "@:>@");
case 47: case 47:
YY_RULE_SETUP YY_RULE_SETUP
#line 184 "scan-gram.l" #line 212 "scan-gram.l"
{ /* End of the comment. */ { /* End of the comment. */
if (yy_top_state () == INITIAL) if (yy_top_state () == INITIAL)
{ {
@@ -1319,28 +1360,28 @@ YY_RULE_SETUP
} }
else else
{ {
YY_GROW; YY_OBS_GROW;
} }
yy_pop_state (); yy_pop_state ();
} }
YY_BREAK YY_BREAK
case 48: case 48:
YY_RULE_SETUP YY_RULE_SETUP
#line 196 "scan-gram.l" #line 224 "scan-gram.l"
if (yy_top_state () != INITIAL) YY_GROW; if (yy_top_state () != INITIAL) YY_OBS_GROW;
YY_BREAK YY_BREAK
case 49: case 49:
YY_RULE_SETUP YY_RULE_SETUP
#line 197 "scan-gram.l" #line 225 "scan-gram.l"
if (yy_top_state () != INITIAL) YY_GROW; YY_LINES; if (yy_top_state () != INITIAL) YY_OBS_GROW; YY_LINES;
YY_BREAK YY_BREAK
case 50: case 50:
YY_RULE_SETUP YY_RULE_SETUP
#line 198 "scan-gram.l" #line 226 "scan-gram.l"
/* Stray `*'. */if (yy_top_state () != INITIAL) YY_GROW; /* Stray `*'. */if (yy_top_state () != INITIAL) YY_OBS_GROW;
YY_BREAK YY_BREAK
case YY_STATE_EOF(SC_COMMENT): case YY_STATE_EOF(SC_COMMENT):
#line 200 "scan-gram.l" #line 228 "scan-gram.l"
{ {
LOCATION_PRINT (stderr, *yylloc); LOCATION_PRINT (stderr, *yylloc);
fprintf (stderr, ": unexpected end of file in a comment\n"); fprintf (stderr, ": unexpected end of file in a comment\n");
@@ -1356,32 +1397,32 @@ case YY_STATE_EOF(SC_COMMENT):
case 51: case 51:
YY_RULE_SETUP YY_RULE_SETUP
#line 215 "scan-gram.l" #line 243 "scan-gram.l"
{ {
assert (yy_top_state () == INITIAL); assert (yy_top_state () == INITIAL);
YY_GROW; YY_OBS_GROW;
YY_FINISH; YY_OBS_FINISH;
yy_pop_state (); yy_pop_state ();
return STRING; return STRING;
} }
YY_BREAK YY_BREAK
case 52: case 52:
YY_RULE_SETUP YY_RULE_SETUP
#line 223 "scan-gram.l" #line 251 "scan-gram.l"
YY_GROW; YY_OBS_GROW;
YY_BREAK YY_BREAK
case 53: case 53:
YY_RULE_SETUP YY_RULE_SETUP
#line 225 "scan-gram.l" #line 253 "scan-gram.l"
obstack_1grow (&string_obstack, '\n'); YY_LINES; obstack_1grow (&string_obstack, '\n'); YY_LINES;
YY_BREAK YY_BREAK
case YY_STATE_EOF(SC_ESCAPED_STRING): case YY_STATE_EOF(SC_ESCAPED_STRING):
#line 227 "scan-gram.l" #line 255 "scan-gram.l"
{ {
LOCATION_PRINT (stderr, *yylloc); LOCATION_PRINT (stderr, *yylloc);
fprintf (stderr, ": unexpected end of file in a string\n"); fprintf (stderr, ": unexpected end of file in a string\n");
assert (yy_top_state () == INITIAL); assert (yy_top_state () == INITIAL);
YY_FINISH; YY_OBS_FINISH;
yy_pop_state (); yy_pop_state ();
return STRING; return STRING;
} }
@@ -1395,17 +1436,16 @@ case YY_STATE_EOF(SC_ESCAPED_STRING):
case 54: case 54:
YY_RULE_SETUP YY_RULE_SETUP
#line 244 "scan-gram.l" #line 272 "scan-gram.l"
{ {
YY_GROW; YY_OBS_GROW;
assert (yy_top_state () == INITIAL); assert (yy_top_state () == INITIAL);
{ {
char c; YY_OBS_FINISH;
YY_FINISH; yylval->symbol = getsym (last_string);
c = yylval->string[1];
yylval->symbol = getsym (yylval->string);
symbol_class_set (yylval->symbol, token_sym); symbol_class_set (yylval->symbol, token_sym);
symbol_user_token_number_set (yylval->symbol, (unsigned int) c); symbol_user_token_number_set (yylval->symbol, last_string[1]);
YY_OBS_FREE;
yy_pop_state (); yy_pop_state ();
return ID; return ID;
} }
@@ -1413,21 +1453,21 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 55: case 55:
YY_RULE_SETUP YY_RULE_SETUP
#line 259 "scan-gram.l" #line 286 "scan-gram.l"
YY_GROW; YY_OBS_GROW;
YY_BREAK YY_BREAK
case 56: case 56:
YY_RULE_SETUP YY_RULE_SETUP
#line 261 "scan-gram.l" #line 288 "scan-gram.l"
obstack_1grow (&string_obstack, '\n'); YY_LINES; obstack_1grow (&string_obstack, '\n'); YY_LINES;
YY_BREAK YY_BREAK
case YY_STATE_EOF(SC_ESCAPED_CHARACTER): case YY_STATE_EOF(SC_ESCAPED_CHARACTER):
#line 263 "scan-gram.l" #line 290 "scan-gram.l"
{ {
LOCATION_PRINT (stderr, *yylloc); LOCATION_PRINT (stderr, *yylloc);
fprintf (stderr, ": unexpected end of file in a character\n"); fprintf (stderr, ": unexpected end of file in a character\n");
assert (yy_top_state () == INITIAL); assert (yy_top_state () == INITIAL);
YY_FINISH; YY_OBS_FINISH;
yy_pop_state (); yy_pop_state ();
return CHARACTER; return CHARACTER;
} }
@@ -1440,7 +1480,7 @@ case YY_STATE_EOF(SC_ESCAPED_CHARACTER):
case 57: case 57:
YY_RULE_SETUP YY_RULE_SETUP
#line 280 "scan-gram.l" #line 307 "scan-gram.l"
{ {
long c = strtol (yytext + 1, 0, 8); long c = strtol (yytext + 1, 0, 8);
if (c > 255) if (c > 255)
@@ -1455,58 +1495,58 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 58: case 58:
YY_RULE_SETUP YY_RULE_SETUP
#line 292 "scan-gram.l" #line 319 "scan-gram.l"
{ {
obstack_1grow (&string_obstack, strtol (yytext + 2, 0, 16)); obstack_1grow (&string_obstack, strtol (yytext + 2, 0, 16));
} }
YY_BREAK YY_BREAK
case 59: case 59:
YY_RULE_SETUP YY_RULE_SETUP
#line 296 "scan-gram.l" #line 323 "scan-gram.l"
obstack_1grow (&string_obstack, '\a'); obstack_1grow (&string_obstack, '\a');
YY_BREAK YY_BREAK
case 60: case 60:
YY_RULE_SETUP YY_RULE_SETUP
#line 297 "scan-gram.l" #line 324 "scan-gram.l"
obstack_1grow (&string_obstack, '\b'); obstack_1grow (&string_obstack, '\b');
YY_BREAK YY_BREAK
case 61: case 61:
YY_RULE_SETUP YY_RULE_SETUP
#line 298 "scan-gram.l" #line 325 "scan-gram.l"
obstack_1grow (&string_obstack, '\f'); obstack_1grow (&string_obstack, '\f');
YY_BREAK YY_BREAK
case 62: case 62:
YY_RULE_SETUP YY_RULE_SETUP
#line 299 "scan-gram.l" #line 326 "scan-gram.l"
obstack_1grow (&string_obstack, '\n'); obstack_1grow (&string_obstack, '\n');
YY_BREAK YY_BREAK
case 63: case 63:
YY_RULE_SETUP YY_RULE_SETUP
#line 300 "scan-gram.l" #line 327 "scan-gram.l"
obstack_1grow (&string_obstack, '\r'); obstack_1grow (&string_obstack, '\r');
YY_BREAK YY_BREAK
case 64: case 64:
YY_RULE_SETUP YY_RULE_SETUP
#line 301 "scan-gram.l" #line 328 "scan-gram.l"
obstack_1grow (&string_obstack, '\t'); obstack_1grow (&string_obstack, '\t');
YY_BREAK YY_BREAK
case 65: case 65:
YY_RULE_SETUP YY_RULE_SETUP
#line 302 "scan-gram.l" #line 329 "scan-gram.l"
obstack_1grow (&string_obstack, '\v'); obstack_1grow (&string_obstack, '\v');
YY_BREAK YY_BREAK
case 66: case 66:
YY_RULE_SETUP YY_RULE_SETUP
#line 303 "scan-gram.l" #line 330 "scan-gram.l"
obstack_1grow (&string_obstack, yytext[1]); obstack_1grow (&string_obstack, yytext[1]);
YY_BREAK YY_BREAK
case 67: case 67:
YY_RULE_SETUP YY_RULE_SETUP
#line 304 "scan-gram.l" #line 331 "scan-gram.l"
{ {
LOCATION_PRINT (stderr, *yylloc); LOCATION_PRINT (stderr, *yylloc);
fprintf (stderr, ": unrecognized escape: %s\n", yytext); fprintf (stderr, ": unrecognized escape: %s\n", yytext);
YY_GROW; YY_OBS_GROW;
} }
YY_BREAK YY_BREAK
@@ -1518,30 +1558,30 @@ YY_RULE_SETUP
case 68: case 68:
YY_RULE_SETUP YY_RULE_SETUP
#line 319 "scan-gram.l" #line 346 "scan-gram.l"
{ {
YY_GROW; YY_OBS_GROW;
assert (yy_top_state () != INITIAL); assert (yy_top_state () != INITIAL);
yy_pop_state (); yy_pop_state ();
} }
YY_BREAK YY_BREAK
case 69: case 69:
YY_RULE_SETUP YY_RULE_SETUP
#line 325 "scan-gram.l" #line 352 "scan-gram.l"
YY_GROW; YY_OBS_GROW;
YY_BREAK YY_BREAK
case 70: case 70:
YY_RULE_SETUP YY_RULE_SETUP
#line 326 "scan-gram.l" #line 353 "scan-gram.l"
YY_GROW; YY_OBS_GROW;
YY_BREAK YY_BREAK
case 71: case 71:
YY_RULE_SETUP YY_RULE_SETUP
#line 328 "scan-gram.l" #line 355 "scan-gram.l"
YY_GROW; YY_LINES; YY_OBS_GROW; YY_LINES;
YY_BREAK YY_BREAK
case YY_STATE_EOF(SC_CHARACTER): case YY_STATE_EOF(SC_CHARACTER):
#line 330 "scan-gram.l" #line 357 "scan-gram.l"
{ {
LOCATION_PRINT (stderr, *yylloc); LOCATION_PRINT (stderr, *yylloc);
fprintf (stderr, ": unexpected end of file in a character\n"); fprintf (stderr, ": unexpected end of file in a character\n");
@@ -1558,30 +1598,30 @@ case YY_STATE_EOF(SC_CHARACTER):
case 72: case 72:
YY_RULE_SETUP YY_RULE_SETUP
#line 346 "scan-gram.l" #line 373 "scan-gram.l"
{ {
assert (yy_top_state () != INITIAL); assert (yy_top_state () != INITIAL);
YY_GROW; YY_OBS_GROW;
yy_pop_state (); yy_pop_state ();
} }
YY_BREAK YY_BREAK
case 73: case 73:
YY_RULE_SETUP YY_RULE_SETUP
#line 352 "scan-gram.l" #line 379 "scan-gram.l"
YY_GROW; YY_OBS_GROW;
YY_BREAK YY_BREAK
case 74: case 74:
YY_RULE_SETUP YY_RULE_SETUP
#line 353 "scan-gram.l" #line 380 "scan-gram.l"
YY_GROW; YY_OBS_GROW;
YY_BREAK YY_BREAK
case 75: case 75:
YY_RULE_SETUP YY_RULE_SETUP
#line 355 "scan-gram.l" #line 382 "scan-gram.l"
YY_GROW; YY_LINES; YY_OBS_GROW; YY_LINES;
YY_BREAK YY_BREAK
case YY_STATE_EOF(SC_STRING): case YY_STATE_EOF(SC_STRING):
#line 357 "scan-gram.l" #line 384 "scan-gram.l"
{ {
LOCATION_PRINT (stderr, *yylloc); LOCATION_PRINT (stderr, *yylloc);
fprintf (stderr, ": unexpected end of file in a string\n"); fprintf (stderr, ": unexpected end of file in a string\n");
@@ -1598,25 +1638,25 @@ case YY_STATE_EOF(SC_STRING):
/* Characters. We don't check there is only one. */ /* Characters. We don't check there is only one. */
case 76: case 76:
YY_RULE_SETUP YY_RULE_SETUP
#line 373 "scan-gram.l" #line 400 "scan-gram.l"
YY_GROW; yy_push_state (SC_CHARACTER); YY_OBS_GROW; yy_push_state (SC_CHARACTER);
YY_BREAK YY_BREAK
/* Strings. */ /* Strings. */
case 77: case 77:
YY_RULE_SETUP YY_RULE_SETUP
#line 376 "scan-gram.l" #line 403 "scan-gram.l"
YY_GROW; yy_push_state (SC_STRING); YY_OBS_GROW; yy_push_state (SC_STRING);
YY_BREAK YY_BREAK
/* Comments. */ /* Comments. */
case 78: case 78:
YY_RULE_SETUP YY_RULE_SETUP
#line 379 "scan-gram.l" #line 406 "scan-gram.l"
YY_GROW; yy_push_state (SC_COMMENT); YY_OBS_GROW; yy_push_state (SC_COMMENT);
YY_BREAK YY_BREAK
case 79: case 79:
YY_RULE_SETUP YY_RULE_SETUP
#line 380 "scan-gram.l" #line 407 "scan-gram.l"
YY_GROW; YY_OBS_GROW;
YY_BREAK YY_BREAK
/*---------------------------------------------------------------. /*---------------------------------------------------------------.
@@ -1627,55 +1667,55 @@ YY_GROW;
case 80: case 80:
YY_RULE_SETUP YY_RULE_SETUP
#line 391 "scan-gram.l" #line 418 "scan-gram.l"
{ {
YY_GROW; YY_OBS_GROW;
if (--braces_level == 0) if (--braces_level == 0)
{ {
yy_pop_state (); yy_pop_state ();
YY_FINISH; YY_OBS_FINISH;
return BRACED_CODE; return BRACED_CODE;
} }
} }
YY_BREAK YY_BREAK
case 81: case 81:
YY_RULE_SETUP YY_RULE_SETUP
#line 401 "scan-gram.l" #line 428 "scan-gram.l"
YY_GROW; braces_level++; YY_OBS_GROW; braces_level++;
YY_BREAK YY_BREAK
case 82: case 82:
YY_RULE_SETUP YY_RULE_SETUP
#line 403 "scan-gram.l" #line 430 "scan-gram.l"
{ handle_dollar (yytext); } { handle_dollar (yytext); }
YY_BREAK YY_BREAK
case 83: case 83:
YY_RULE_SETUP YY_RULE_SETUP
#line 404 "scan-gram.l" #line 431 "scan-gram.l"
{ handle_at (yytext); } { handle_at (yytext); }
YY_BREAK YY_BREAK
case 84: case 84:
YY_RULE_SETUP YY_RULE_SETUP
#line 406 "scan-gram.l" #line 433 "scan-gram.l"
YY_GROW; YY_OBS_GROW;
YY_BREAK YY_BREAK
case 85: case 85:
YY_RULE_SETUP YY_RULE_SETUP
#line 407 "scan-gram.l" #line 434 "scan-gram.l"
YY_GROW; YY_LINES; YY_OBS_GROW; YY_LINES;
YY_BREAK YY_BREAK
/* A lose $, or /, or etc. */ /* A lose $, or /, or etc. */
case 86: case 86:
YY_RULE_SETUP YY_RULE_SETUP
#line 410 "scan-gram.l" #line 437 "scan-gram.l"
YY_GROW; YY_OBS_GROW;
YY_BREAK YY_BREAK
case YY_STATE_EOF(SC_BRACED_CODE): case YY_STATE_EOF(SC_BRACED_CODE):
#line 412 "scan-gram.l" #line 439 "scan-gram.l"
{ {
LOCATION_PRINT (stderr, *yylloc); LOCATION_PRINT (stderr, *yylloc);
fprintf (stderr, ": unexpected end of file in a braced code\n"); fprintf (stderr, ": unexpected end of file in a braced code\n");
yy_pop_state (); yy_pop_state ();
YY_FINISH; YY_OBS_FINISH;
return PROLOGUE; return PROLOGUE;
} }
YY_BREAK YY_BREAK
@@ -1687,35 +1727,35 @@ case YY_STATE_EOF(SC_BRACED_CODE):
case 87: case 87:
YY_RULE_SETUP YY_RULE_SETUP
#line 429 "scan-gram.l" #line 456 "scan-gram.l"
{ {
yy_pop_state (); yy_pop_state ();
YY_FINISH; YY_OBS_FINISH;
return PROLOGUE; return PROLOGUE;
} }
YY_BREAK YY_BREAK
case 88: case 88:
YY_RULE_SETUP YY_RULE_SETUP
#line 435 "scan-gram.l" #line 462 "scan-gram.l"
YY_GROW; YY_OBS_GROW;
YY_BREAK YY_BREAK
case 89: case 89:
YY_RULE_SETUP YY_RULE_SETUP
#line 436 "scan-gram.l" #line 463 "scan-gram.l"
YY_GROW; YY_OBS_GROW;
YY_BREAK YY_BREAK
case 90: case 90:
YY_RULE_SETUP YY_RULE_SETUP
#line 437 "scan-gram.l" #line 464 "scan-gram.l"
YY_GROW; YY_LINES; YY_OBS_GROW; YY_LINES;
YY_BREAK YY_BREAK
case YY_STATE_EOF(SC_PROLOGUE): case YY_STATE_EOF(SC_PROLOGUE):
#line 439 "scan-gram.l" #line 466 "scan-gram.l"
{ {
LOCATION_PRINT (stderr, *yylloc); LOCATION_PRINT (stderr, *yylloc);
fprintf (stderr, ": unexpected end of file in a prologue\n"); fprintf (stderr, ": unexpected end of file in a prologue\n");
yy_pop_state (); yy_pop_state ();
YY_FINISH; YY_OBS_FINISH;
return PROLOGUE; return PROLOGUE;
} }
YY_BREAK YY_BREAK
@@ -1728,24 +1768,24 @@ case YY_STATE_EOF(SC_PROLOGUE):
case 91: case 91:
YY_RULE_SETUP YY_RULE_SETUP
#line 457 "scan-gram.l" #line 484 "scan-gram.l"
YY_GROW; YY_OBS_GROW;
YY_BREAK YY_BREAK
case YY_STATE_EOF(SC_EPILOGUE): case YY_STATE_EOF(SC_EPILOGUE):
#line 459 "scan-gram.l" #line 486 "scan-gram.l"
{ {
yy_pop_state (); yy_pop_state ();
YY_FINISH; YY_OBS_FINISH;
return EPILOGUE; return EPILOGUE;
} }
YY_BREAK YY_BREAK
case 92: case 92:
YY_RULE_SETUP YY_RULE_SETUP
#line 467 "scan-gram.l" #line 494 "scan-gram.l"
YY_FATAL_ERROR( "flex scanner jammed" ); YY_FATAL_ERROR( "flex scanner jammed" );
YY_BREAK YY_BREAK
#line 1749 "scan-gram.c" #line 1789 "scan-gram.c"
case YY_STATE_EOF(INITIAL): case YY_STATE_EOF(INITIAL):
yyterminate(); yyterminate();
@@ -2309,11 +2349,15 @@ YY_BUFFER_STATE b;
} }
#ifndef _WIN32
#include <unistd.h>
#else
#ifndef YY_ALWAYS_INTERACTIVE #ifndef YY_ALWAYS_INTERACTIVE
#ifndef YY_NEVER_INTERACTIVE #ifndef YY_NEVER_INTERACTIVE
extern int isatty YY_PROTO(( int )); extern int isatty YY_PROTO(( int ));
#endif #endif
#endif #endif
#endif
#ifdef YY_USE_PROTOS #ifdef YY_USE_PROTOS
void yy_init_buffer( YY_BUFFER_STATE b, FILE *file ) void yy_init_buffer( YY_BUFFER_STATE b, FILE *file )
@@ -2631,7 +2675,7 @@ int main()
return 0; return 0;
} }
#endif #endif
#line 467 "scan-gram.l" #line 494 "scan-gram.l"
/*------------------------------------------------------------------. /*------------------------------------------------------------------.

View File

@@ -35,15 +35,42 @@
#define YY_LINES LOCATION_LINES (*yylloc, yyleng); lineno += yyleng; #define YY_LINES LOCATION_LINES (*yylloc, yyleng); lineno += yyleng;
#define YY_STEP LOCATION_STEP (*yylloc) #define YY_STEP LOCATION_STEP (*yylloc)
/* Appending to the STRING_OBSTACK. */
#define YY_INIT obstack_init (&string_obstack) /* STRING_OBSTACK -- Used to store all the characters that we need to
#define YY_GROW obstack_grow (&string_obstack, yytext, yyleng) keep (to construct ID, STRINGS etc.). Use the following macros to
#define YY_FINISH obstack_1grow (&string_obstack, '\0'); yylval->string = obstack_finish (&string_obstack); use it.
Use YY_OBS_INIT to initialize a new growing string, YY_OBS_GROW to
append what has just been matched, and YY_OBS_FINISH to end the
string (it puts the ending 0). YY_OBS_FINISH also stores this
string in LAST_STRING, which can be used, and which is used by
YY_OBS_FREE to free the last string. */
static struct obstack string_obstack;
char *last_string;
#define YY_OBS_INIT \
obstack_init (&string_obstack)
#define YY_OBS_GROW \
obstack_grow (&string_obstack, yytext, yyleng)
#define YY_OBS_FINISH \
do { \
obstack_1grow (&string_obstack, '\0'); \
last_string = obstack_finish (&string_obstack); \
yylval->string = last_string; \
} while (0)
#define YY_OBS_FREE \
do { \
obstack_free (&string_obstack, last_string); \
} while (0)
/* This is only to avoid GCC warnings. */ /* This is only to avoid GCC warnings. */
#define YY_USER_INIT if (yycontrol) {;}; #define YY_USER_INIT if (yycontrol) {;};
static struct obstack string_obstack;
static int braces_level = 0; static int braces_level = 0;
static int percent_percent_count = 0; static int percent_percent_count = 0;
@@ -121,31 +148,32 @@ blanks [ \t\f]+
{eols} YY_LINES; YY_STEP; {eols} YY_LINES; YY_STEP;
{blanks} YY_STEP; {blanks} YY_STEP;
{id} { {id} {
YY_INIT; YY_GROW; YY_FINISH; YY_OBS_INIT; YY_OBS_GROW; YY_OBS_FINISH;
yylval->symbol = getsym (yylval->string); yylval->symbol = getsym (last_string);
YY_OBS_FREE;
return ID; return ID;
} }
{int} yylval->integer = strtol (yytext, 0, 10); return INT; {int} yylval->integer = strtol (yytext, 0, 10); return INT;
/* Characters. We don't check there is only one. */ /* Characters. We don't check there is only one. */
\' YY_INIT; YY_GROW; yy_push_state (SC_ESCAPED_CHARACTER); \' YY_OBS_INIT; YY_OBS_GROW; yy_push_state (SC_ESCAPED_CHARACTER);
/* Strings. */ /* Strings. */
\" YY_INIT; YY_GROW; yy_push_state (SC_ESCAPED_STRING); \" YY_OBS_INIT; YY_OBS_GROW; yy_push_state (SC_ESCAPED_STRING);
/* Comments. */ /* Comments. */
"/*" yy_push_state (SC_COMMENT); "/*" yy_push_state (SC_COMMENT);
"//".* YY_STEP; "//".* YY_STEP;
/* Prologue. */ /* Prologue. */
"%{" YY_INIT; yy_push_state (SC_PROLOGUE); "%{" YY_OBS_INIT; yy_push_state (SC_PROLOGUE);
/* Code in between braces. */ /* Code in between braces. */
"{" 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);
/* A type. */ /* A type. */
"<"[^>]+">" 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;
"%%" { "%%" {
if (++percent_percent_count == 2) if (++percent_percent_count == 2)
@@ -188,14 +216,14 @@ blanks [ \t\f]+
} }
else else
{ {
YY_GROW; YY_OBS_GROW;
} }
yy_pop_state (); yy_pop_state ();
} }
[^\[\]*\n\r]+ if (yy_top_state () != INITIAL) YY_GROW; [^\[\]*\n\r]+ if (yy_top_state () != INITIAL) YY_OBS_GROW;
{eols} if (yy_top_state () != INITIAL) YY_GROW; YY_LINES; {eols} if (yy_top_state () != INITIAL) YY_OBS_GROW; YY_LINES;
. /* Stray `*'. */if (yy_top_state () != INITIAL) YY_GROW; . /* Stray `*'. */if (yy_top_state () != INITIAL) YY_OBS_GROW;
<<EOF>> { <<EOF>> {
LOCATION_PRINT (stderr, *yylloc); LOCATION_PRINT (stderr, *yylloc);
@@ -214,13 +242,13 @@ blanks [ \t\f]+
{ {
\" { \" {
assert (yy_top_state () == INITIAL); assert (yy_top_state () == INITIAL);
YY_GROW; YY_OBS_GROW;
YY_FINISH; YY_OBS_FINISH;
yy_pop_state (); yy_pop_state ();
return STRING; return STRING;
} }
[^\"\n\r\\]+ YY_GROW; [^\"\n\r\\]+ YY_OBS_GROW;
{eols} obstack_1grow (&string_obstack, '\n'); YY_LINES; {eols} obstack_1grow (&string_obstack, '\n'); YY_LINES;
@@ -228,7 +256,7 @@ blanks [ \t\f]+
LOCATION_PRINT (stderr, *yylloc); LOCATION_PRINT (stderr, *yylloc);
fprintf (stderr, ": unexpected end of file in a string\n"); fprintf (stderr, ": unexpected end of file in a string\n");
assert (yy_top_state () == INITIAL); assert (yy_top_state () == INITIAL);
YY_FINISH; YY_OBS_FINISH;
yy_pop_state (); yy_pop_state ();
return STRING; return STRING;
} }
@@ -242,21 +270,20 @@ blanks [ \t\f]+
<SC_ESCAPED_CHARACTER> <SC_ESCAPED_CHARACTER>
{ {
\' { \' {
YY_GROW; YY_OBS_GROW;
assert (yy_top_state () == INITIAL); assert (yy_top_state () == INITIAL);
{ {
char c; YY_OBS_FINISH;
YY_FINISH; yylval->symbol = getsym (last_string);
c = yylval->string[1];
yylval->symbol = getsym (yylval->string);
symbol_class_set (yylval->symbol, token_sym); symbol_class_set (yylval->symbol, token_sym);
symbol_user_token_number_set (yylval->symbol, (unsigned int) c); symbol_user_token_number_set (yylval->symbol, last_string[1]);
YY_OBS_FREE;
yy_pop_state (); yy_pop_state ();
return ID; return ID;
} }
} }
[^\'\n\r\\] YY_GROW; [^\'\n\r\\] YY_OBS_GROW;
{eols} obstack_1grow (&string_obstack, '\n'); YY_LINES; {eols} obstack_1grow (&string_obstack, '\n'); YY_LINES;
@@ -264,7 +291,7 @@ blanks [ \t\f]+
LOCATION_PRINT (stderr, *yylloc); LOCATION_PRINT (stderr, *yylloc);
fprintf (stderr, ": unexpected end of file in a character\n"); fprintf (stderr, ": unexpected end of file in a character\n");
assert (yy_top_state () == INITIAL); assert (yy_top_state () == INITIAL);
YY_FINISH; YY_OBS_FINISH;
yy_pop_state (); yy_pop_state ();
return CHARACTER; return CHARACTER;
} }
@@ -304,7 +331,7 @@ blanks [ \t\f]+
\\. { \\. {
LOCATION_PRINT (stderr, *yylloc); LOCATION_PRINT (stderr, *yylloc);
fprintf (stderr, ": unrecognized escape: %s\n", yytext); fprintf (stderr, ": unrecognized escape: %s\n", yytext);
YY_GROW; YY_OBS_GROW;
} }
} }
@@ -317,15 +344,15 @@ blanks [ \t\f]+
<SC_CHARACTER> <SC_CHARACTER>
{ {
\' { \' {
YY_GROW; YY_OBS_GROW;
assert (yy_top_state () != INITIAL); assert (yy_top_state () != INITIAL);
yy_pop_state (); yy_pop_state ();
} }
[^\[\]\'\n\r\\] YY_GROW; [^\[\]\'\n\r\\] YY_OBS_GROW;
\\. YY_GROW; \\. YY_OBS_GROW;
{eols} YY_GROW; YY_LINES; {eols} YY_OBS_GROW; YY_LINES;
<<EOF>> { <<EOF>> {
LOCATION_PRINT (stderr, *yylloc); LOCATION_PRINT (stderr, *yylloc);
@@ -345,14 +372,14 @@ blanks [ \t\f]+
{ {
\" { \" {
assert (yy_top_state () != INITIAL); assert (yy_top_state () != INITIAL);
YY_GROW; YY_OBS_GROW;
yy_pop_state (); yy_pop_state ();
} }
[^\[\]\"\n\r\\]+ YY_GROW; [^\[\]\"\n\r\\]+ YY_OBS_GROW;
\\. YY_GROW; \\. YY_OBS_GROW;
{eols} YY_GROW; YY_LINES; {eols} YY_OBS_GROW; YY_LINES;
<<EOF>> { <<EOF>> {
LOCATION_PRINT (stderr, *yylloc); LOCATION_PRINT (stderr, *yylloc);
@@ -370,14 +397,14 @@ blanks [ \t\f]+
<SC_BRACED_CODE,SC_PROLOGUE,SC_EPILOGUE> <SC_BRACED_CODE,SC_PROLOGUE,SC_EPILOGUE>
{ {
/* Characters. We don't check there is only one. */ /* Characters. We don't check there is only one. */
\' YY_GROW; yy_push_state (SC_CHARACTER); \' YY_OBS_GROW; yy_push_state (SC_CHARACTER);
/* Strings. */ /* Strings. */
\" YY_GROW; yy_push_state (SC_STRING); \" YY_OBS_GROW; yy_push_state (SC_STRING);
/* Comments. */ /* Comments. */
"/*" YY_GROW; yy_push_state (SC_COMMENT); "/*" YY_OBS_GROW; yy_push_state (SC_COMMENT);
"//".* YY_GROW; "//".* YY_OBS_GROW;
} }
@@ -389,31 +416,31 @@ blanks [ \t\f]+
<SC_BRACED_CODE> <SC_BRACED_CODE>
{ {
"}" { "}" {
YY_GROW; YY_OBS_GROW;
if (--braces_level == 0) if (--braces_level == 0)
{ {
yy_pop_state (); yy_pop_state ();
YY_FINISH; YY_OBS_FINISH;
return BRACED_CODE; return BRACED_CODE;
} }
} }
"{" YY_GROW; braces_level++; "{" YY_OBS_GROW; braces_level++;
"$"("<".*">")?(-?[0-9]+|"$") { handle_dollar (yytext); } "$"("<".*">")?(-?[0-9]+|"$") { handle_dollar (yytext); }
"@"(-?[0-9]+|"$") { handle_at (yytext); } "@"(-?[0-9]+|"$") { handle_at (yytext); }
[^\[\]$/\'\"@\{\}\n\r]+ YY_GROW; [^\[\]$/\'\"@\{\}\n\r]+ YY_OBS_GROW;
{eols} YY_GROW; YY_LINES; {eols} YY_OBS_GROW; YY_LINES;
/* A lose $, or /, or etc. */ /* A lose $, or /, or etc. */
. YY_GROW; . YY_OBS_GROW;
<<EOF>> { <<EOF>> {
LOCATION_PRINT (stderr, *yylloc); LOCATION_PRINT (stderr, *yylloc);
fprintf (stderr, ": unexpected end of file in a braced code\n"); fprintf (stderr, ": unexpected end of file in a braced code\n");
yy_pop_state (); yy_pop_state ();
YY_FINISH; YY_OBS_FINISH;
return PROLOGUE; return PROLOGUE;
} }
@@ -428,19 +455,19 @@ blanks [ \t\f]+
{ {
"%}" { "%}" {
yy_pop_state (); yy_pop_state ();
YY_FINISH; YY_OBS_FINISH;
return PROLOGUE; return PROLOGUE;
} }
[^\[\]%\n\r]+ YY_GROW; [^\[\]%\n\r]+ YY_OBS_GROW;
"%"+[^%\}\n\r]+ YY_GROW; "%"+[^%\}\n\r]+ YY_OBS_GROW;
{eols} YY_GROW; YY_LINES; {eols} YY_OBS_GROW; YY_LINES;
<<EOF>> { <<EOF>> {
LOCATION_PRINT (stderr, *yylloc); LOCATION_PRINT (stderr, *yylloc);
fprintf (stderr, ": unexpected end of file in a prologue\n"); fprintf (stderr, ": unexpected end of file in a prologue\n");
yy_pop_state (); yy_pop_state ();
YY_FINISH; YY_OBS_FINISH;
return PROLOGUE; return PROLOGUE;
} }
@@ -454,11 +481,11 @@ blanks [ \t\f]+
<SC_EPILOGUE> <SC_EPILOGUE>
{ {
([^\[\]]|{eols})+ YY_GROW; ([^\[\]]|{eols})+ YY_OBS_GROW;
<<EOF>> { <<EOF>> {
yy_pop_state (); yy_pop_state ();
YY_FINISH; YY_OBS_FINISH;
return EPILOGUE; return EPILOGUE;
} }
} }