X-Git-Url: https://git.saurik.com/bison.git/blobdiff_plain/676385e29c4aedfc05d20daf1ef20cd4ccc84856..d1a1114f7f257f89887ea5825ba0d896dfaa747b:/src/scan-gram.c?ds=sidebyside diff --git a/src/scan-gram.c b/src/scan-gram.c index cb71d622..7457d949 100644 --- a/src/scan-gram.c +++ b/src/scan-gram.c @@ -15,7 +15,7 @@ #define yyrestart gram_restart #define yytext gram_text -#line 19 "scan-gram.c" +#line 19 "lex.yy.c" /* A lexical scanner generated by flex */ /* Scanner skeleton version: @@ -27,7 +27,7 @@ #define YY_FLEX_MINOR_VERSION 5 #include - +#include /* cfront 1.2 defines "c_plusplus" instead of "__cplusplus" */ #ifdef c_plusplus @@ -40,7 +40,9 @@ #ifdef __cplusplus #include +#ifndef _WIN32 #include +#endif /* Use prototypes in function declarations. */ #define YY_USE_PROTOS @@ -497,7 +499,7 @@ static yyconst short int yy_nxt[891] = { 0, 20, 21, 22, 23, 24, 20, 25, 26, 20, 20, 27, 28, 29, 29, 30, 31, 32, 33, 20, 20, - 27, 20, 20, 20, 20, 27, 27, 27, 27, 27, + 27, 20, 20, 20, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 34, 35, 20, 37, 38, 112, 37, 38, 113, 39, 89, 90, 39, @@ -708,11 +710,11 @@ static yyconst short int yy_rule_linenum[101] = 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 155, 156, 157, 158, 160, 161, 162, 167, 170, 173, 176, 177, 180, 183, 186, 194, 200, 216, - 217, 228, 240, 241, 242, 259, 268, 270, 290, 304, - 306, 326, 338, 342, 343, 344, 345, 346, 347, 348, - 349, 350, 356, 367, 373, 374, 376, 378, 396, 402, - 403, 405, 407, 425, 428, 431, 432, 435, 446, 457, - 459, 461, 464, 465, 468, 488, 495, 496, 497, 517 + 217, 228, 240, 241, 242, 259, 268, 270, 290, 305, + 307, 327, 339, 343, 344, 345, 346, 347, 348, 349, + 350, 351, 357, 368, 374, 375, 377, 379, 397, 403, + 404, 406, 408, 426, 429, 432, 433, 436, 447, 458, + 460, 462, 465, 466, 469, 489, 496, 497, 498, 518 } ; @@ -761,14 +763,14 @@ char *yytext; #define YY_USER_INIT \ do { \ LOCATION_RESET (*yylloc); \ + yylloc->file = infile; \ /* This is only to avoid GCC warnings. */ \ if (yycontrol) {;}; \ } while (0) -#define YY_USER_ACTION LOCATION_COLUMNS (*yylloc, yyleng) -#define YY_LINES LOCATION_LINES (*yylloc, yyleng); lineno += yyleng; -#define YY_STEP LOCATION_STEP (*yylloc) - +#define YY_USER_ACTION LOCATION_COLUMNS (*yylloc, yyleng); +#define YY_LINES LOCATION_LINES (*yylloc, yyleng); +#define YY_STEP LOCATION_STEP (*yylloc); /* STRING_OBSTACK -- Used to store all the characters that we need to keep (to construct ID, STRINGS etc.). Use the following macros to @@ -823,7 +825,7 @@ static void handle_at PARAMS ((braced_code_t code_kind, #define SC_PROLOGUE 7 #define SC_EPILOGUE 8 -#line 827 "scan-gram.c" +#line 829 "lex.yy.c" /* Macros after this point can all be overridden by user definitions in * section 1. @@ -923,9 +925,20 @@ YY_MALLOC_DECL YY_FATAL_ERROR( "input in flex scanner failed" ); \ result = n; \ } \ - else if ( ((result = fread( buf, 1, max_size, yyin )) == 0) \ - && ferror( yyin ) ) \ - YY_FATAL_ERROR( "input in flex scanner failed" ); + else \ + { \ + 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 /* No semi-colon after return; correct usage is to write "yyterminate();" - @@ -997,7 +1010,7 @@ YY_DECL /*----------------------------. | Scanning Bison directives. | `----------------------------*/ -#line 1001 "scan-gram.c" +#line 1014 "lex.yy.c" if ( yy_init ) { @@ -1291,7 +1304,7 @@ case 39: YY_RULE_SETUP #line 162 "scan-gram.l" { - yylval->symbol = getsym (yytext, *yylloc); + yylval->symbol = symbol_get (yytext, *yylloc); return ID; } YY_BREAK @@ -1360,7 +1373,7 @@ YY_RULE_SETUP #line 200 "scan-gram.l" { LOCATION_PRINT (stderr, *yylloc); - fprintf (stderr, ": invalid character: `%c'\n", *yytext); + fprintf (stderr, _(": invalid character: `%c'\n"), *yytext); YY_STEP; } YY_BREAK @@ -1422,7 +1435,7 @@ case YY_STATE_EOF(SC_COMMENT): #line 244 "scan-gram.l" { LOCATION_PRINT (stderr, *yylloc); - fprintf (stderr, ": unexpected end of file in a comment\n"); + fprintf (stderr, _(": unexpected end of file in a comment\n")); yy_pop_state (); } YY_BREAK @@ -1459,7 +1472,7 @@ case YY_STATE_EOF(SC_ESCAPED_STRING): #line 272 "scan-gram.l" { 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); YY_OBS_FINISH; yylval->string = last_string; @@ -1482,9 +1495,10 @@ YY_RULE_SETUP assert (yy_top_state () == INITIAL); { YY_OBS_FINISH; - yylval->symbol = getsym (last_string, *yylloc); + yylval->symbol = symbol_get (last_string, *yylloc); symbol_class_set (yylval->symbol, token_sym, *yylloc); - symbol_user_token_number_set (yylval->symbol, last_string[1], *yylloc); + symbol_user_token_number_set (yylval->symbol, + (unsigned char) last_string[1], *yylloc); YY_OBS_FREE; yy_pop_state (); return ID; @@ -1493,19 +1507,19 @@ YY_RULE_SETUP YY_BREAK case 60: YY_RULE_SETUP -#line 304 "scan-gram.l" +#line 305 "scan-gram.l" YY_OBS_GROW; YY_BREAK case 61: YY_RULE_SETUP -#line 306 "scan-gram.l" +#line 307 "scan-gram.l" obstack_1grow (&string_obstack, '\n'); YY_LINES; YY_BREAK case YY_STATE_EOF(SC_ESCAPED_CHARACTER): -#line 308 "scan-gram.l" +#line 309 "scan-gram.l" { 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); YY_OBS_FINISH; yylval->string = last_string; @@ -1521,13 +1535,13 @@ case YY_STATE_EOF(SC_ESCAPED_CHARACTER): case 62: YY_RULE_SETUP -#line 326 "scan-gram.l" +#line 327 "scan-gram.l" { long c = strtol (yytext + 1, 0, 8); if (c > 255) { LOCATION_PRINT (stderr, *yylloc); - fprintf (stderr, ": invalid escape: %s\n", quote (yytext)); + fprintf (stderr, _(": invalid escape: %s\n"), quote (yytext)); YY_STEP; } else @@ -1536,64 +1550,64 @@ YY_RULE_SETUP YY_BREAK case 63: YY_RULE_SETUP -#line 338 "scan-gram.l" +#line 339 "scan-gram.l" { obstack_1grow (&string_obstack, strtol (yytext + 2, 0, 16)); } YY_BREAK case 64: YY_RULE_SETUP -#line 342 "scan-gram.l" +#line 343 "scan-gram.l" obstack_1grow (&string_obstack, '\a'); YY_BREAK case 65: YY_RULE_SETUP -#line 343 "scan-gram.l" +#line 344 "scan-gram.l" obstack_1grow (&string_obstack, '\b'); YY_BREAK case 66: YY_RULE_SETUP -#line 344 "scan-gram.l" +#line 345 "scan-gram.l" obstack_1grow (&string_obstack, '\f'); YY_BREAK case 67: YY_RULE_SETUP -#line 345 "scan-gram.l" +#line 346 "scan-gram.l" obstack_1grow (&string_obstack, '\n'); YY_BREAK case 68: YY_RULE_SETUP -#line 346 "scan-gram.l" +#line 347 "scan-gram.l" obstack_1grow (&string_obstack, '\r'); YY_BREAK case 69: YY_RULE_SETUP -#line 347 "scan-gram.l" +#line 348 "scan-gram.l" obstack_1grow (&string_obstack, '\t'); YY_BREAK case 70: YY_RULE_SETUP -#line 348 "scan-gram.l" +#line 349 "scan-gram.l" obstack_1grow (&string_obstack, '\v'); YY_BREAK case 71: YY_RULE_SETUP -#line 349 "scan-gram.l" +#line 350 "scan-gram.l" obstack_1grow (&string_obstack, yytext[1]); YY_BREAK case 72: YY_RULE_SETUP -#line 350 "scan-gram.l" +#line 351 "scan-gram.l" { LOCATION_PRINT (stderr, *yylloc); - fprintf (stderr, ": unrecognized escape: %s\n", quote (yytext)); + fprintf (stderr, _(": unrecognized escape: %s\n"), quote (yytext)); YY_OBS_GROW; } YY_BREAK /* FLex wants this rule, in case of a `\<>'. */ case 73: YY_RULE_SETUP -#line 356 "scan-gram.l" +#line 357 "scan-gram.l" YY_OBS_GROW; YY_BREAK @@ -1605,7 +1619,7 @@ YY_OBS_GROW; case 74: YY_RULE_SETUP -#line 367 "scan-gram.l" +#line 368 "scan-gram.l" { YY_OBS_GROW; assert (yy_top_state () != INITIAL); @@ -1614,30 +1628,30 @@ YY_RULE_SETUP YY_BREAK case 75: YY_RULE_SETUP -#line 373 "scan-gram.l" +#line 374 "scan-gram.l" YY_OBS_GROW; YY_BREAK case 76: YY_RULE_SETUP -#line 374 "scan-gram.l" +#line 375 "scan-gram.l" YY_OBS_GROW; YY_BREAK /* FLex wants this rule, in case of a `\<>'. */ case 77: YY_RULE_SETUP -#line 376 "scan-gram.l" +#line 377 "scan-gram.l" YY_OBS_GROW; YY_BREAK case 78: YY_RULE_SETUP -#line 378 "scan-gram.l" +#line 379 "scan-gram.l" YY_OBS_GROW; YY_LINES; YY_BREAK case YY_STATE_EOF(SC_CHARACTER): -#line 380 "scan-gram.l" +#line 381 "scan-gram.l" { 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); yy_pop_state (); } @@ -1651,7 +1665,7 @@ case YY_STATE_EOF(SC_CHARACTER): case 79: YY_RULE_SETUP -#line 396 "scan-gram.l" +#line 397 "scan-gram.l" { assert (yy_top_state () != INITIAL); YY_OBS_GROW; @@ -1660,30 +1674,30 @@ YY_RULE_SETUP YY_BREAK case 80: YY_RULE_SETUP -#line 402 "scan-gram.l" +#line 403 "scan-gram.l" YY_OBS_GROW; YY_BREAK case 81: YY_RULE_SETUP -#line 403 "scan-gram.l" +#line 404 "scan-gram.l" YY_OBS_GROW; YY_BREAK /* FLex wants this rule, in case of a `\<>'. */ case 82: YY_RULE_SETUP -#line 405 "scan-gram.l" +#line 406 "scan-gram.l" YY_OBS_GROW; YY_BREAK case 83: YY_RULE_SETUP -#line 407 "scan-gram.l" +#line 408 "scan-gram.l" YY_OBS_GROW; YY_LINES; YY_BREAK case YY_STATE_EOF(SC_STRING): -#line 409 "scan-gram.l" +#line 410 "scan-gram.l" { 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); yy_pop_state (); } @@ -1697,30 +1711,30 @@ case YY_STATE_EOF(SC_STRING): /* Characters. We don't check there is only one. */ case 84: YY_RULE_SETUP -#line 425 "scan-gram.l" +#line 426 "scan-gram.l" YY_OBS_GROW; yy_push_state (SC_CHARACTER); YY_BREAK /* Strings. */ case 85: YY_RULE_SETUP -#line 428 "scan-gram.l" +#line 429 "scan-gram.l" YY_OBS_GROW; yy_push_state (SC_STRING); YY_BREAK /* Comments. */ case 86: YY_RULE_SETUP -#line 431 "scan-gram.l" +#line 432 "scan-gram.l" YY_OBS_GROW; yy_push_state (SC_COMMENT); YY_BREAK case 87: YY_RULE_SETUP -#line 432 "scan-gram.l" +#line 433 "scan-gram.l" YY_OBS_GROW; YY_BREAK /* Not comments. */ case 88: YY_RULE_SETUP -#line 435 "scan-gram.l" +#line 436 "scan-gram.l" YY_OBS_GROW; YY_BREAK @@ -1732,7 +1746,7 @@ YY_OBS_GROW; case 89: YY_RULE_SETUP -#line 446 "scan-gram.l" +#line 447 "scan-gram.l" { YY_OBS_GROW; if (--braces_level == 0) @@ -1746,42 +1760,42 @@ YY_RULE_SETUP YY_BREAK case 90: YY_RULE_SETUP -#line 457 "scan-gram.l" +#line 458 "scan-gram.l" YY_OBS_GROW; braces_level++; YY_BREAK case 91: YY_RULE_SETUP -#line 459 "scan-gram.l" +#line 460 "scan-gram.l" { handle_dollar (current_braced_code, yytext, *yylloc); } YY_BREAK case 92: YY_RULE_SETUP -#line 461 "scan-gram.l" +#line 462 "scan-gram.l" { handle_at (current_braced_code, yytext, *yylloc); } YY_BREAK case 93: YY_RULE_SETUP -#line 464 "scan-gram.l" +#line 465 "scan-gram.l" YY_OBS_GROW; YY_BREAK case 94: YY_RULE_SETUP -#line 465 "scan-gram.l" +#line 466 "scan-gram.l" YY_OBS_GROW; YY_LINES; YY_BREAK /* A lose $, or /, or etc. */ case 95: YY_RULE_SETUP -#line 468 "scan-gram.l" +#line 469 "scan-gram.l" YY_OBS_GROW; YY_BREAK case YY_STATE_EOF(SC_BRACED_CODE): -#line 470 "scan-gram.l" +#line 471 "scan-gram.l" { 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_OBS_FINISH; yylval->string = last_string; @@ -1796,7 +1810,7 @@ case YY_STATE_EOF(SC_BRACED_CODE): case 96: YY_RULE_SETUP -#line 488 "scan-gram.l" +#line 489 "scan-gram.l" { yy_pop_state (); YY_OBS_FINISH; @@ -1806,24 +1820,24 @@ YY_RULE_SETUP YY_BREAK case 97: YY_RULE_SETUP -#line 495 "scan-gram.l" +#line 496 "scan-gram.l" YY_OBS_GROW; YY_BREAK case 98: YY_RULE_SETUP -#line 496 "scan-gram.l" +#line 497 "scan-gram.l" YY_OBS_GROW; YY_BREAK case 99: YY_RULE_SETUP -#line 497 "scan-gram.l" +#line 498 "scan-gram.l" YY_OBS_GROW; YY_LINES; YY_BREAK case YY_STATE_EOF(SC_PROLOGUE): -#line 499 "scan-gram.l" +#line 500 "scan-gram.l" { 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_OBS_FINISH; yylval->string = last_string; @@ -1839,11 +1853,11 @@ case YY_STATE_EOF(SC_PROLOGUE): case 100: YY_RULE_SETUP -#line 517 "scan-gram.l" +#line 518 "scan-gram.l" YY_OBS_GROW; YY_BREAK case YY_STATE_EOF(SC_EPILOGUE): -#line 519 "scan-gram.l" +#line 520 "scan-gram.l" { yy_pop_state (); YY_OBS_FINISH; @@ -1854,10 +1868,10 @@ case YY_STATE_EOF(SC_EPILOGUE): case 101: YY_RULE_SETUP -#line 528 "scan-gram.l" +#line 529 "scan-gram.l" YY_FATAL_ERROR( "flex scanner jammed" ); YY_BREAK -#line 1861 "scan-gram.c" +#line 1875 "lex.yy.c" case YY_STATE_EOF(INITIAL): yyterminate(); @@ -2421,11 +2435,15 @@ YY_BUFFER_STATE b; } +#ifndef _WIN32 +#include +#else #ifndef YY_ALWAYS_INTERACTIVE #ifndef YY_NEVER_INTERACTIVE extern int isatty YY_PROTO(( int )); #endif #endif +#endif #ifdef YY_USE_PROTOS void yy_init_buffer( YY_BUFFER_STATE b, FILE *file ) @@ -2743,7 +2761,7 @@ int main() return 0; } #endif -#line 528 "scan-gram.l" +#line 529 "scan-gram.l" /*------------------------------------------------------------------. @@ -2776,13 +2794,13 @@ handle_action_dollar (char *text, location_t location) type_name = symbol_list_n_type_name_get (current_rule, location, 0); if (!type_name && typed) complain_at (location, _("$$ of `%s' has no declared type"), - symbol_tag_get (current_rule->sym)); + current_rule->sym->tag); if (!type_name) type_name = ""; obstack_fgrow1 (&string_obstack, "]b4_lhs_value([%s])[", type_name); } - else if (isdigit (*cp) || *cp == '-') + else if (('0' <= *cp && *cp <= '9') || *cp == '-') { /* RULE_LENGTH is the number of values in the current rule so far, which says where to find `$0' with respect to the top of @@ -2800,7 +2818,7 @@ handle_action_dollar (char *text, location_t location) n); if (!type_name && typed) complain_at (location, _("$%d of `%s' has no declared type"), - n, symbol_tag_get (current_rule->sym)); + n, current_rule->sym->tag); if (!type_name) type_name = ""; obstack_fgrow3 (&string_obstack, @@ -2869,7 +2887,7 @@ handle_action_at (char *text, location_t location) { obstack_sgrow (&string_obstack, "]b4_lhs_location["); } - else if (isdigit (*cp) || *cp == '-') + else if (('0' <= *cp && *cp <= '9') || *cp == '-') { /* RULE_LENGTH is the number of values in the current rule so far, which says where to find `$0' with respect to the top of @@ -2949,4 +2967,6 @@ void scanner_free (void) { obstack_free (&string_obstack, 0); + /* Reclaim Flex's buffers. */ + yy_delete_buffer (YY_CURRENT_BUFFER); }