X-Git-Url: https://git.saurik.com/bison.git/blobdiff_plain/c527b2d4834cad9389a32992c70aafbefe729424..e9f87b5b7df2e328d2e4196d276c0d96594c906b:/src/bison.simple diff --git a/src/bison.simple b/src/bison.simple index de23187a..207395fc 100644 --- a/src/bison.simple +++ b/src/bison.simple @@ -1,7 +1,8 @@ +%%{section} %%{body} %%".c" %%{yacc} /* -*- C -*- */ -/* A Bison parser, made from %%filename - by GNU bison %%version. */ +/* A Bison parser, made from %%{filename} + by GNU bison %%{version}. */ /* Skeleton output parser for bison, Copyright 1984, 1989, 1990, 2000, 2001 Free Software Foundation, Inc. @@ -35,14 +36,31 @@ #define YYBISON 1 /* Pure parsers. */ -#define YYPURE %%pure +#define YYPURE %%{pure} /* Using locations. */ -#define YYLSP_NEEDED %%locations-flag +#define YYLSP_NEEDED %%{locations-flag} + +/* If NAME_PREFIX is specified substitute the variables and functions + names. */ +#define yyparse %%{prefix}parse +#define yylex %%{prefix}lex +#define yyerror %%{prefix}error +#define yylval %%{prefix}lval +#define yychar %%{prefix}char +#define yydebug %%{prefix}debug +#define yynerrs %%{prefix}nerrs +#if YYLSP_NEEDED +# define yylloc %%{prefix}lloc +#endif + + +/* Copy the user declarations. */ +%%{prologue} /* Enabling traces. */ #ifndef YYDEBUG -# define YYDEBUG %%debug +# define YYDEBUG %%{debug} #endif /* Enabling verbose error messages. */ @@ -50,21 +68,11 @@ # undef YYERROR_VERBOSE # define YYERROR_VERBOSE 1 #else -# define YYERROR_VERBOSE %%error-verbose +# define YYERROR_VERBOSE %%{error-verbose} #endif -/* If name_prefix is specify substitute the variables and functions - names. */ -#define yyparse %%prefix##parse -#define yylex %%prefix##lex -#define yyerror %%prefix##error -#define yylval %%prefix##lval -#define yychar %%prefix##char -#define yydebug %%prefix##debug -#define yynerrs %%prefix##nerrs - #ifndef YYSTYPE -typedef %%stype yystype; +typedef %%{stype} yystype; # define YYSTYPE yystype #endif @@ -76,16 +84,11 @@ typedef struct yyltype int last_line; int last_column; } yyltype; -# define YYLTYPE %%ltype +# define YYLTYPE %%{ltype} #endif -/* Copy the user declarations. */ -%%prologue - -/* Line 85 of bison.simple. */ -#line %%line "%%parser-file-name" - -#include +/* Line %%{skeleton-line} of %%{skeleton}. */ +#line %%{line} "%%{parser-file-name}" /* All symbols defined below should begin with yy or YY, to avoid infringing on user name space. This should be done even for local @@ -94,32 +97,28 @@ typedef struct yyltype define necessary library symbols; they are noted "INFRINGES ON USER NAME SPACE" below. */ -#if ! defined (yyoverflow) || YYERROR_VERBOSE +#ifdef __cplusplus +# define YYSTD(x) std::x +#else +# define YYSTD(x) x +#endif + +#if ! defined (yyoverflow) || defined (YYERROR_VERBOSE) /* The parser invokes alloca or malloc; define the necessary symbols. */ # if YYSTACK_USE_ALLOCA # define YYSTACK_ALLOC alloca -# define YYSIZE_T size_t +# define YYSIZE_T YYSTD (size_t) # else # ifndef YYSTACK_USE_ALLOCA # if defined (alloca) || defined (_ALLOCA_H) # define YYSTACK_ALLOC alloca -# define YYSIZE_T size_t +# define YYSIZE_T YYSTD (size_t) # else -# if defined (__GNUC__) || defined (_AIX) || defined (__hpux) +# ifdef __GNUC__ # define YYSTACK_ALLOC __builtin_alloca # endif -# ifndef __GNUC__ -# ifdef _AIX - # pragma alloca -# endif -# if defined (__sgi) || defined (__sparc__) || defined (__sparc) || defined (__sun) -# include /* INFRINGES ON USER NAME SPACE */ -# define YYSTACK_ALLOC alloca -# define YYSIZE_T size_t -# endif -# endif # endif # endif # endif @@ -131,16 +130,14 @@ typedef struct yyltype # ifdef __cplusplus # include /* INFRINGES ON USER NAME SPACE */ # define YYSIZE_T std::size_t -# define YYSTACK_ALLOC std::malloc -# define YYSTACK_FREE std::free # else # ifdef __STDC__ # include /* INFRINGES ON USER NAME SPACE */ # define YYSIZE_T size_t # endif -# define YYSTACK_ALLOC malloc -# define YYSTACK_FREE free # endif +# define YYSTACK_ALLOC YYSTD (malloc) +# define YYSTACK_FREE YYSTD (free) # endif /* A type that is properly aligned for any stack member. */ @@ -188,70 +185,78 @@ union yyalloc #endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */ /* Tokens. */ -%%tokendef - -#define YYFINAL %%final -#define YYFLAG %%flag -#define YYNTBASE %%ntbase -#define YYLAST %%last - -#define YYNTOKENS %%ntokens -#define YYNNTS %%nnts -#define YYNRULES %%nrules -#define YYNSTATES %%nstates -#define YYMAXUTOK %%maxtok - -/* YYTRANSLATE(YYLEX) -- Bison token number corresponding to YYLEX. */ -#define YYTRANSLATE(x) ((unsigned)(x) <= %%maxtok ? yytranslate[x] : %%nsym) - -/* YYTRANSLATE[YYLEX] -- Bison token number corresponding to YYLEX. */ +%%{tokendef} + +/* YYFINAL -- State number of the termination state. */ +#define YYFINAL %%{final} +#define YYFLAG %%{flag} +#define YYLAST %%{last} + +/* YYNTOKENS -- Number of terminals. */ +#define YYNTOKENS %%{ntokens} +/* YYNNTS -- Number of nonterminals. */ +#define YYNNTS %%{nnts} +/* YYNRULES -- Number of rules. */ +#define YYNRULES %%{nrules} +/* YYNRULES -- Number of states. */ +#define YYNSTATES %%{nstates} +#define YYMAXUTOK %%{maxtok} + +/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ +#define YYTRANSLATE(x) ((unsigned)(x) <= %%{maxtok} ? yytranslate[x] : %%{nsym}) + +/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */ static const char yytranslate[] = { - %%translate + %%{translate} }; #if YYDEBUG +/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in + YYRHS. */ static const short yyprhs[] = { - %%prhs + %%{prhs} }; +/* YYRHS -- A `-1'-separated list of the rules' RHS. */ static const short yyrhs[] = { - %%rhs + %%{rhs} }; /* YYRLINE[YYN] -- source line where rule number YYN was defined. */ static const short yyrline[] = { - %%rline + %%{rline} }; #endif #if (YYDEBUG) || YYERROR_VERBOSE -/* YYTNME[TOKEN_NUM] -- String name of the token TOKEN_NUM. */ +/* YYTNME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. + First, the terminals, then, starting at YYNTOKENS, nonterminals. */ static const char *const yytname[] = { - %%tname + %%{tname} }; #endif /* YYTOKNUM[YYN] -- Index in YYTNAME corresponding to YYLEX. */ static const short yytoknum[] = { - %%toknum + %%{toknum} }; /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ static const short yyr1[] = { - %%r1 + %%{r1} }; /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ static const short yyr2[] = { - %%r2 + %%{r2} }; /* YYDEFACT[S] -- default rule to reduce with in state S when YYTABLE @@ -259,32 +264,39 @@ static const short yyr2[] = error. */ static const short yydefact[] = { - %%defact + %%{defact} }; +/* YYPGOTO[NTERM-NUM]. */ static const short yydefgoto[] = { - %%defgoto + %%{defgoto} }; +/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing + STATE-NUM. */ static const short yypact[] = { - %%pact + %%{pact} }; +/* YYPGOTO[NTERM-NUM]. */ static const short yypgoto[] = { - %%pgoto + %%{pgoto} }; +/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If + positive, shift that token. If negative, reduce the rule which + number is the opposite. If zero, do what YYDEFACT says. */ static const short yytable[] = { - %%table + %%{table} }; static const short yycheck[] = { - %%check + %%{check} }; @@ -331,14 +343,14 @@ do \ if (yychar == YYEMPTY && yylen == 1) \ { \ yychar = (Token); \ - yylval = (Value); \ + yylval = (Value); \ yychar1 = YYTRANSLATE (yychar); \ YYPOPSTACK; \ goto yybackup; \ } \ else \ { \ - yyerror ("syntax error: cannot back up"); \ + yyerror ("syntax error: cannot back up"); \ YYERROR; \ } \ while (0) @@ -384,14 +396,11 @@ while (0) # ifndef YYFPRINTF # ifdef __cplusplus -# include /* INFRINGES ON USER NAME SPACE */ -# define YYFPRINTF std::fprintf -# define YYSTDERR std::stderr +# include /* INFRINGES ON USER NAME SPACE */ # else # include /* INFRINGES ON USER NAME SPACE */ -# define YYFPRINTF fprintf -# define YYSTDERR stderr # endif +# define YYFPRINTF YYSTD (fprintf) # endif # define YYDPRINTF(Args) \ @@ -410,7 +419,7 @@ int yydebug; /* YYINITDEPTH -- initial size of the parser's stacks. */ #ifndef YYINITDEPTH -# define YYINITDEPTH %%initdepth +# define YYINITDEPTH %%{initdepth} #endif /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only @@ -425,7 +434,7 @@ int yydebug; #endif #ifndef YYMAXDEPTH -# define YYMAXDEPTH %%maxdepth +# define YYMAXDEPTH %%{maxdepth} #endif @@ -631,7 +640,7 @@ yyparse (YYPARSE_PARAM_ARG) rule. */ int yylen; - YYDPRINTF ((YYSTDERR, "Starting parse\n")); + YYDPRINTF ((stderr, "Starting parse\n")); yystate = 0; yyerrstatus = 0; @@ -727,14 +736,14 @@ yyparse (YYPARSE_PARAM_ARG) yylsp = yyls + yysize - 1; #endif - YYDPRINTF ((YYSTDERR, "Stack size increased to %lu\n", + YYDPRINTF ((stderr, "Stack size increased to %lu\n", (unsigned long int) yystacksize)); if (yyssp >= yyss + yystacksize - 1) YYABORT; } - YYDPRINTF ((YYSTDERR, "Entering state %d\n", yystate)); + YYDPRINTF ((stderr, "Entering state %d\n", yystate)); goto yybackup; @@ -760,7 +769,7 @@ yybackup: if (yychar == YYEMPTY) { - YYDPRINTF ((YYSTDERR, "Reading a token: ")); + YYDPRINTF ((stderr, "Reading a token: ")); yychar = YYLEX; } @@ -771,7 +780,7 @@ yybackup: yychar1 = 0; yychar = YYEOF; /* Don't call YYLEX any more. */ - YYDPRINTF ((YYSTDERR, "Now at end of input.\n")); + YYDPRINTF ((stderr, "Now at end of input.\n")); } else { @@ -782,14 +791,14 @@ yybackup: which are defined only if `YYDEBUG' is set. */ if (yydebug) { - YYFPRINTF (YYSTDERR, "Next token is %d (%s", + YYFPRINTF (stderr, "Next token is %d (%s", yychar, yytname[yychar1]); /* Give the individual parser a way to print the precise meaning of a token, for further debugging info. */ # ifdef YYPRINT - YYPRINT (YYSTDERR, yychar, yylval); + YYPRINT (stderr, yychar, yylval); # endif - YYFPRINTF (YYSTDERR, ")\n"); + YYFPRINTF (stderr, ")\n"); } #endif } @@ -821,7 +830,7 @@ yybackup: YYACCEPT; /* Shift the lookahead token. */ - YYDPRINTF ((YYSTDERR, "Shifting token %d (%s), ", + YYDPRINTF ((stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1])); /* Discard the token being shifted unless it is eof. */ @@ -883,21 +892,22 @@ yyreduce: { int yyi; - YYFPRINTF (YYSTDERR, "Reducing via rule %d (line %d), ", - yyn, yyrline[yyn]); + YYFPRINTF (stderr, "Reducing via rule %d (line %d), ", + yyn - 1, yyrline[yyn]); /* Print the symbols being reduced, and their result. */ - for (yyi = yyprhs[yyn]; yyrhs[yyi] > 0; yyi++) - YYFPRINTF (YYSTDERR, "%s ", yytname[yyrhs[yyi]]); - YYFPRINTF (YYSTDERR, " -> %s\n", yytname[yyr1[yyn]]); + for (yyi = yyprhs[yyn]; yyrhs[yyi] >= 0; yyi++) + YYFPRINTF (stderr, "%s ", yytname[yyrhs[yyi]]); + YYFPRINTF (stderr, " -> %s\n", yytname[yyr1[yyn]]); } #endif switch (yyn) { -%%actions + %%{actions} } - /* Line 902 of bison.simple. */ -#line %%line "%%parser-file-name" + +/* Line %%{skeleton-line} of %%{skeleton}. */ +#line %%{line} "%%{parser-file-name}" yyvsp -= yylen; yyssp -= yylen; @@ -909,10 +919,10 @@ yyreduce: if (yydebug) { short *yyssp1 = yyss - 1; - YYFPRINTF (YYSTDERR, "state stack now"); + YYFPRINTF (stderr, "state stack now"); while (yyssp1 != yyssp) - YYFPRINTF (YYSTDERR, " %d", *++yyssp1); - YYFPRINTF (YYSTDERR, "\n"); + YYFPRINTF (stderr, " %d", *++yyssp1); + YYFPRINTF (stderr, "\n"); } #endif @@ -927,11 +937,11 @@ yyreduce: yyn = yyr1[yyn]; - yystate = yypgoto[yyn - YYNTBASE] + *yyssp; + yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp) yystate = yytable[yystate]; else - yystate = yydefgoto[yyn - YYNTBASE]; + yystate = yydefgoto[yyn - YYNTOKENS]; goto yynewstate; @@ -1008,7 +1018,7 @@ yyerrlab1: /* Return failure if at end of input. */ if (yychar == YYEOF) YYABORT; - YYDPRINTF ((YYSTDERR, "Discarding token %d (%s).\n", + YYDPRINTF ((stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1])); yychar = YYEMPTY; } @@ -1054,10 +1064,10 @@ yyerrpop: if (yydebug) { short *yyssp1 = yyss - 1; - YYFPRINTF (YYSTDERR, "Error: state stack now"); + YYFPRINTF (stderr, "Error: state stack now"); while (yyssp1 != yyssp) - YYFPRINTF (YYSTDERR, " %d", *++yyssp1); - YYFPRINTF (YYSTDERR, "\n"); + YYFPRINTF (stderr, " %d", *++yyssp1); + YYFPRINTF (stderr, "\n"); } #endif @@ -1087,7 +1097,7 @@ yyerrhandle: if (yyn == YYFINAL) YYACCEPT; - YYDPRINTF ((YYSTDERR, "Shifting error token, ")); + YYDPRINTF ((stderr, "Shifting error token, ")); *++yyvsp = yylval; #if YYLSP_NEEDED @@ -1128,4 +1138,4 @@ yyreturn: return yyresult; } -%%epilogue +%%{epilogue}