X-Git-Url: https://git.saurik.com/bison.git/blobdiff_plain/b7575ffe6f9ca88b6a3f45a499f6e3e76757b862..e9f87b5b7df2e328d2e4196d276c0d96594c906b:/src/bison.simple?ds=sidebyside diff --git a/src/bison.simple b/src/bison.simple index c7b56562..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,32 +36,43 @@ #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. */ -#undef YYERROR_VERBOSE -#define YYERROR_VERBOSE %%error-verbose - -/* 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 +#ifdef YYERROR_VERBOSE +# undef YYERROR_VERBOSE +# define YYERROR_VERBOSE 1 +#else +# define YYERROR_VERBOSE %%{error-verbose} +#endif #ifndef YYSTYPE -typedef %%stype yystype; +typedef %%{stype} yystype; # define YYSTYPE yystype #endif @@ -72,15 +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 %%line "%%skeleton" - -#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 @@ -89,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 @@ -126,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. */ @@ -183,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. */ +#if (YYDEBUG) || YYERROR_VERBOSE +/* 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 @@ -254,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} }; @@ -326,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) @@ -379,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) \ @@ -405,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 @@ -420,7 +434,7 @@ int yydebug; #endif #ifndef YYMAXDEPTH -# define YYMAXDEPTH %%maxdepth +# define YYMAXDEPTH %%{maxdepth} #endif @@ -507,8 +521,6 @@ yystpcpy (yydest, yysrc) -#line %%line "%%skeleton" - /* The user can define YYPARSE_PARAM as the name of an argument to be passed into yyparse. The argument should have type void *. It should actually point to an object. @@ -628,7 +640,7 @@ yyparse (YYPARSE_PARAM_ARG) rule. */ int yylen; - YYDPRINTF ((YYSTDERR, "Starting parse\n")); + YYDPRINTF ((stderr, "Starting parse\n")); yystate = 0; yyerrstatus = 0; @@ -724,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; @@ -757,7 +769,7 @@ yybackup: if (yychar == YYEMPTY) { - YYDPRINTF ((YYSTDERR, "Reading a token: ")); + YYDPRINTF ((stderr, "Reading a token: ")); yychar = YYLEX; } @@ -768,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 { @@ -779,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 } @@ -818,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. */ @@ -880,20 +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) { - %%action + %%{actions} } -#line %%line "%%skeleton" + +/* Line %%{skeleton-line} of %%{skeleton}. */ +#line %%{line} "%%{parser-file-name}" yyvsp -= yylen; yyssp -= yylen; @@ -905,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 @@ -923,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; @@ -1004,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; } @@ -1050,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 @@ -1083,7 +1097,7 @@ yyerrhandle: if (yyn == YYFINAL) YYACCEPT; - YYDPRINTF ((YYSTDERR, "Shifting error token, ")); + YYDPRINTF ((stderr, "Shifting error token, ")); *++yyvsp = yylval; #if YYLSP_NEEDED @@ -1124,4 +1138,4 @@ yyreturn: return yyresult; } -%%epilogue +%%{epilogue}