X-Git-Url: https://git.saurik.com/bison.git/blobdiff_plain/6088a2a04d926bb02528ed420f15743fd10e341d..5f3df3960e71e210c190001d2a34b2a73ea01d6a:/src/parse-gram.c diff --git a/src/parse-gram.c b/src/parse-gram.c index 59c0923a..ba5b09bc 100644 --- a/src/parse-gram.c +++ b/src/parse-gram.c @@ -1,4 +1,4 @@ -/* A Bison parser, made by GNU Bison 2.0a. */ +/* A Bison parser, made by GNU Bison 2.0b. */ /* Skeleton parser for Yacc-like parsing with Bison, Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. @@ -217,12 +217,12 @@ static void gram_error (location const *, char const *); static void add_param (char const *, char *, location); -symbol_class current_class = unknown_sym; -uniqstr current_type = 0; +static symbol_class current_class = unknown_sym; +static uniqstr current_type = 0; symbol *current_lhs; location current_lhs_location; assoc current_assoc; -int current_prec = 0; +static int current_prec = 0; /* Enabling traces. */ @@ -238,6 +238,11 @@ int current_prec = 0; # define YYERROR_VERBOSE 1 #endif +/* Enabling the token table. */ +#ifndef YYTOKEN_TABLE +# define YYTOKEN_TABLE 0 +#endif + #if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED) #line 79 "parse-gram.y" typedef union YYSTYPE { @@ -248,8 +253,8 @@ typedef union YYSTYPE { assoc assoc; uniqstr uniqstr; } YYSTYPE; -/* Line 191 of yacc.c. */ -#line 253 "parse-gram.c" +/* Line 196 of yacc.c. */ +#line 258 "parse-gram.c" # define yystype YYSTYPE /* obsolescent; will be withdrawn */ # define YYSTYPE_IS_DECLARED 1 # define YYSTYPE_IS_TRIVIAL 1 @@ -272,8 +277,8 @@ typedef struct YYLTYPE /* Copy the second part of user declarations. */ -/* Line 214 of yacc.c. */ -#line 277 "parse-gram.c" +/* Line 219 of yacc.c. */ +#line 282 "parse-gram.c" #if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__) # define YYSIZE_T __SIZE_TYPE__ @@ -441,7 +446,7 @@ union yyalloc #define YYUNDEFTOK 2 #define YYMAXUTOK 305 -#define YYTRANSLATE(YYX) \ +#define YYTRANSLATE(YYX) \ ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */ @@ -535,21 +540,24 @@ static const unsigned short int yyrline[] = }; #endif -#if YYDEBUG || YYERROR_VERBOSE -/* YYTNME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. +#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE +/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. First, the terminals, then, starting at YYNTOKENS, nonterminals. */ static const char *const yytname[] = { - "end of file", "error", "$undefined", "string", "integer", "%token", - "%nterm", "%type", "%destructor {...}", "%printer {...}", "%union {...}", - "%left", "%right", "%nonassoc", "%prec", "%dprec", "%merge", "%debug", - "%default-prec", "%define", "%defines", "%error-verbose", "%expect", - "%expect-rr", "%file-prefix", "%glr-parser", "%initial-action {...}", - "%lex-param {...}", "%locations", "%name-prefix", "%no-default-prec", - "%no-lines", "%nondeterministic-parser", "%output", "%parse-param {...}", - "%pure-parser", "%skeleton", "%start", "%token-table", "%verbose", - "%yacc", "type", "=", ";", "|", "identifier", "identifier:", "%%", - "%{...%}", "epilogue", "{...}", "$accept", "input", "declarations", + "\"end of file\"", "error", "$undefined", "\"string\"", "\"integer\"", + "\"%token\"", "\"%nterm\"", "\"%type\"", "\"%destructor {...}\"", + "\"%printer {...}\"", "\"%union {...}\"", "\"%left\"", "\"%right\"", + "\"%nonassoc\"", "\"%prec\"", "\"%dprec\"", "\"%merge\"", "\"%debug\"", + "\"%default-prec\"", "\"%define\"", "\"%defines\"", "\"%error-verbose\"", + "\"%expect\"", "\"%expect-rr\"", "\"%file-prefix\"", "\"%glr-parser\"", + "\"%initial-action {...}\"", "\"%lex-param {...}\"", "\"%locations\"", + "\"%name-prefix\"", "\"%no-default-prec\"", "\"%no-lines\"", + "\"%nondeterministic-parser\"", "\"%output\"", "\"%parse-param {...}\"", + "\"%pure-parser\"", "\"%skeleton\"", "\"%start\"", "\"%token-table\"", + "\"%verbose\"", "\"%yacc\"", "\"type\"", "\"=\"", "\";\"", "\"|\"", + "\"identifier\"", "\"identifier:\"", "\"%%\"", "\"%{...%}\"", + "\"epilogue\"", "\"{...}\"", "$accept", "input", "declarations", "declaration", "grammar_declaration", "symbol_declaration", "@1", "@2", "precedence_declaration", "precedence_declarator", "type.opt", "symbols.1", "symbol_def", "symbol_defs.1", "grammar", @@ -741,7 +749,7 @@ do \ goto yybackup; \ } \ else \ - { \ + { \ yyerror (YY_("syntax error: cannot back up")); \ YYERROR; \ } \ @@ -821,7 +829,7 @@ do { \ if (yydebug) \ { \ YYFPRINTF (stderr, "%s ", Title); \ - yysymprint (stderr, \ + yysymprint (stderr, \ Type, Value, Location); \ YYFPRINTF (stderr, "\n"); \ } \ @@ -874,8 +882,8 @@ yy_reduce_print (yyrule) yyrule - 1, yylno); /* Print the symbols being reduced, and their result. */ for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++) - YYFPRINTF (stderr, "%s ", yytname [yyrhs[yyi]]); - YYFPRINTF (stderr, "-> %s\n", yytname [yyr1[yyrule]]); + YYFPRINTF (stderr, "%s ", yytname[yyrhs[yyi]]); + YYFPRINTF (stderr, "-> %s\n", yytname[yyr1[yyrule]]); } # define YY_REDUCE_PRINT(Rule) \ @@ -964,7 +972,55 @@ yystpcpy (yydest, yysrc) # endif # endif -#endif /* !YYERROR_VERBOSE */ +# ifndef yytnamerr +/* Copy to YYRES the contents of YYSTR after stripping away unnecessary + quotes and backslashes, so that it's suitable for yyerror. The + heuristic is that double-quoting is unnecessary unless the string + contains an apostrophe, a comma, or backslash (other than + backslash-backslash). YYSTR is taken from yytname. If YYRES is + null, do not copy; instead, return the length of what the result + would have been. */ +static YYSIZE_T +yytnamerr (char *yyres, const char *yystr) +{ + if (*yystr == '"') + { + size_t yyn = 0; + char const *yyp = yystr; + + for (;;) + switch (*++yyp) + { + case '\'': + case ',': + goto do_not_strip_quotes; + + case '\\': + if (*++yyp != '\\') + goto do_not_strip_quotes; + /* Fall through. */ + default: + if (yyres) + yyres[yyn] = *yyp; + yyn++; + break; + + case '"': + if (yyres) + yyres[yyn] = '\0'; + return yyn; + } + do_not_strip_quotes: ; + } + + if (! yyres) + return yystrlen (yystr); + + return yystpcpy (yyres, yystr) - yyres; +} +# endif + +#endif /* YYERROR_VERBOSE */ @@ -1006,92 +1062,92 @@ yysymprint (yyoutput, yytype, yyvaluep, yylocationp) case 3: /* "\"string\"" */ #line 165 "parse-gram.y" { fprintf (stderr, "\"%s\"", (yyvaluep->chars)); }; -#line 1010 "parse-gram.c" +#line 1066 "parse-gram.c" break; case 4: /* "\"integer\"" */ #line 178 "parse-gram.y" { fprintf (stderr, "%d", (yyvaluep->integer)); }; -#line 1015 "parse-gram.c" +#line 1071 "parse-gram.c" break; case 8: /* "\"%destructor {...}\"" */ #line 167 "parse-gram.y" { fprintf (stderr, "{\n%s\n}", (yyvaluep->chars)); }; -#line 1020 "parse-gram.c" +#line 1076 "parse-gram.c" break; case 9: /* "\"%printer {...}\"" */ #line 171 "parse-gram.y" { fprintf (stderr, "{\n%s\n}", (yyvaluep->chars)); }; -#line 1025 "parse-gram.c" +#line 1081 "parse-gram.c" break; case 10: /* "\"%union {...}\"" */ #line 172 "parse-gram.y" { fprintf (stderr, "{\n%s\n}", (yyvaluep->chars)); }; -#line 1030 "parse-gram.c" +#line 1086 "parse-gram.c" break; case 26: /* "\"%initial-action {...}\"" */ #line 168 "parse-gram.y" { fprintf (stderr, "{\n%s\n}", (yyvaluep->chars)); }; -#line 1035 "parse-gram.c" +#line 1091 "parse-gram.c" break; case 27: /* "\"%lex-param {...}\"" */ #line 169 "parse-gram.y" { fprintf (stderr, "{\n%s\n}", (yyvaluep->chars)); }; -#line 1040 "parse-gram.c" +#line 1096 "parse-gram.c" break; case 34: /* "\"%parse-param {...}\"" */ #line 170 "parse-gram.y" { fprintf (stderr, "{\n%s\n}", (yyvaluep->chars)); }; -#line 1045 "parse-gram.c" +#line 1101 "parse-gram.c" break; case 41: /* "\"type\"" */ #line 176 "parse-gram.y" { fprintf (stderr, "<%s>", (yyvaluep->uniqstr)); }; -#line 1050 "parse-gram.c" +#line 1106 "parse-gram.c" break; case 45: /* "\"identifier\"" */ #line 180 "parse-gram.y" { fprintf (stderr, "%s", (yyvaluep->symbol)->tag); }; -#line 1055 "parse-gram.c" +#line 1111 "parse-gram.c" break; case 46: /* "\"identifier:\"" */ #line 182 "parse-gram.y" { fprintf (stderr, "%s:", (yyvaluep->symbol)->tag); }; -#line 1060 "parse-gram.c" +#line 1116 "parse-gram.c" break; case 48: /* "\"%{...%}\"" */ #line 174 "parse-gram.y" { fprintf (stderr, "{\n%s\n}", (yyvaluep->chars)); }; -#line 1065 "parse-gram.c" +#line 1121 "parse-gram.c" break; case 49: /* "\"epilogue\"" */ #line 174 "parse-gram.y" { fprintf (stderr, "{\n%s\n}", (yyvaluep->chars)); }; -#line 1070 "parse-gram.c" +#line 1126 "parse-gram.c" break; case 50: /* "\"{...}\"" */ #line 173 "parse-gram.y" { fprintf (stderr, "{\n%s\n}", (yyvaluep->chars)); }; -#line 1075 "parse-gram.c" +#line 1131 "parse-gram.c" break; case 71: /* "symbol" */ #line 180 "parse-gram.y" { fprintf (stderr, "%s", (yyvaluep->symbol)->tag); }; -#line 1080 "parse-gram.c" +#line 1136 "parse-gram.c" break; case 72: /* "action" */ #line 173 "parse-gram.y" { fprintf (stderr, "{\n%s\n}", (yyvaluep->chars)); }; -#line 1085 "parse-gram.c" +#line 1141 "parse-gram.c" break; case 73: /* "string_as_id" */ #line 180 "parse-gram.y" { fprintf (stderr, "%s", (yyvaluep->symbol)->tag); }; -#line 1090 "parse-gram.c" +#line 1146 "parse-gram.c" break; case 74: /* "string_content" */ #line 165 "parse-gram.y" { fprintf (stderr, "\"%s\"", (yyvaluep->chars)); }; -#line 1095 "parse-gram.c" +#line 1151 "parse-gram.c" break; default: break; @@ -1172,7 +1228,7 @@ yyparse (void) #else int yyparse () - + ; #endif #endif { @@ -1264,8 +1320,8 @@ YYLTYPE yylloc; yylloc.start.line = yylloc.end.line = 1; yylloc.start.column = yylloc.end.column = 0; } -/* Line 877 of yacc.c. */ -#line 1269 "parse-gram.c" +/* Line 930 of yacc.c. */ +#line 1325 "parse-gram.c" yylsp[0] = yylloc; goto yysetstate; @@ -1847,8 +1903,8 @@ yyreduce: default: break; } -/* Line 1073 of yacc.c. */ -#line 1852 "parse-gram.c" +/* Line 1126 of yacc.c. */ +#line 1908 "parse-gram.c" yyvsp -= yylen; yyssp -= yylen; @@ -1888,7 +1944,7 @@ yyerrlab: if (YYPACT_NINF < yyn && yyn < YYLAST) { int yytype = YYTRANSLATE (yychar); - YYSIZE_T yysize0 = yystrlen (yytname[yytype]); + YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]); YYSIZE_T yysize = yysize0; YYSIZE_T yysize1; int yysize_overflow = 0; @@ -1940,7 +1996,7 @@ yyerrlab: break; } yyarg[yycount++] = yytname[yyx]; - yysize1 = yysize + yystrlen (yytname[yyx]); + yysize1 = yysize + yytnamerr (0, yytname[yyx]); yysize_overflow |= yysize1 < yysize; yysize = yysize1; yyfmt = yystpcpy (yyfmt, yyprefix); @@ -1965,7 +2021,7 @@ yyerrlab: { if (*yyp == '%' && yyf[1] == 's' && yyi < yycount) { - yyp = yystpcpy (yyp, yyarg[yyi++]); + yyp += yytnamerr (yyp, yyarg[yyi++]); yyf += 2; } else @@ -1997,8 +2053,7 @@ yyerrlab: if (yychar <= YYEOF) { - /* If at end of input, pop the error token, - then the rest of the stack, then return failure. */ + /* Return failure if at end of input. */ if (yychar == YYEOF) YYABORT; } @@ -2110,16 +2165,12 @@ yyreturn: if (yychar != YYEOF && yychar != YYEMPTY) yydestruct ("Error: discarding lookahead", yytoken, &yylval, &yylloc); - if (yyssp != yyss) - for (;;) - { - yyerror_range[0] = *yylsp; - YYPOPSTACK; - if (yyssp == yyss) - break; - yydestruct ("Error: popping", - yystos[*yyssp], yyvsp, yylsp); - } + while (yyssp != yyss) + { + yydestruct ("Error: popping", + yystos[*yyssp], yyvsp, yylsp); + YYPOPSTACK; + } #ifndef yyoverflow if (yyss != yyssa) YYSTACK_FREE (yyss);