X-Git-Url: https://git.saurik.com/bison.git/blobdiff_plain/710ddc4f18039668a7672c8670eb3e010b59292a..b85810aec0e5172c813b1cdd511bfce8a0cd4b4f:/src/bison.simple?ds=inline diff --git a/src/bison.simple b/src/bison.simple index 1385e1a4..59ff145b 100644 --- a/src/bison.simple +++ b/src/bison.simple @@ -1,10 +1,11 @@ +%%{section} %%{output-prefix} %%{output-infix} %%".c" /* -*- 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. + Copyright 1984, 1989, 1990, 2000, 2001, 2002 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -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,55 +84,41 @@ 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 - -#ifndef __cplusplus -# ifndef __STDC__ -# define const -# endif -#endif +/* 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 variables, as they might otherwise be expanded by user macros. There are some unavoidable exceptions within include files to - define necessary C library symbols; they are noted "INFRINGES ON + 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 @@ -129,12 +127,17 @@ typedef struct yyltype /* Pacify GCC's `empty if-body' warning. */ # define YYSTACK_FREE(Ptr) do { /* empty */; } while (0) # else -# define YYSTACK_ALLOC malloc -# define YYSTACK_FREE(Ptr) free (Ptr) -# if defined (__STDC__) || defined (__cplusplus) -# include /* INFRINGES ON USER NAME SPACE */ -# define YYSIZE_T size_t +# ifdef __cplusplus +# include /* INFRINGES ON USER NAME SPACE */ +# define YYSIZE_T std::size_t +# else +# ifdef __STDC__ +# include /* INFRINGES ON USER NAME SPACE */ +# define YYSIZE_T size_t +# endif # endif +# define YYSTACK_ALLOC YYSTD (malloc) +# define YYSTACK_FREE YYSTD (free) # endif /* A type that is properly aligned for any stack member. */ @@ -182,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 @@ -253,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} }; @@ -288,9 +306,16 @@ static const short yycheck[] = #if ! defined (YYSIZE_T) && defined (size_t) # define YYSIZE_T size_t #endif -#if ! defined (YYSIZE_T) && (defined (__STDC__) || defined (__cplusplus)) -# include /* INFRINGES ON USER NAME SPACE */ -# define YYSIZE_T size_t +#if ! defined (YYSIZE_T) +# ifdef __cplusplus +# include /* INFRINGES ON USER NAME SPACE */ +# define YYSIZE_T std::size_t +# else +# ifdef __STDC__ +# include /* INFRINGES ON USER NAME SPACE */ +# define YYSIZE_T size_t +# endif +# endif #endif #if ! defined (YYSIZE_T) # define YYSIZE_T unsigned int @@ -318,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) @@ -368,11 +393,20 @@ while (0) /* Enable debugging if requested. */ #if YYDEBUG -# include + +# ifndef YYFPRINTF +# ifdef __cplusplus +# include /* INFRINGES ON USER NAME SPACE */ +# else +# include /* INFRINGES ON USER NAME SPACE */ +# endif +# define YYFPRINTF YYSTD (fprintf) +# endif + # define YYDPRINTF(Args) \ do { \ if (yydebug) \ - fprintf Args; \ + YYFPRINTF Args; \ } while (0) /* Nonzero means print parse trace. [The following comment makes no sense to me. Could someone clarify it? --akim] Since this is @@ -385,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 @@ -400,7 +434,7 @@ int yydebug; #endif #ifndef YYMAXDEPTH -# define YYMAXDEPTH %%maxdepth +# define YYMAXDEPTH %%{maxdepth} #endif @@ -487,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. @@ -759,13 +791,14 @@ yybackup: which are defined only if `YYDEBUG' is set. */ if (yydebug) { - fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]); + 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 (stderr, yychar, yylval); # endif - fprintf (stderr, ")\n"); + YYFPRINTF (stderr, ")\n"); } #endif } @@ -797,7 +830,8 @@ yybackup: YYACCEPT; /* Shift the lookahead token. */ - YYDPRINTF ((stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1])); + YYDPRINTF ((stderr, "Shifting token %d (%s), ", + yychar, yytname[yychar1])); /* Discard the token being shifted unless it is eof. */ if (yychar != YYEOF) @@ -858,20 +892,22 @@ yyreduce: { int yyi; - fprintf (stderr, "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++) - fprintf (stderr, "%s ", yytname[yyrhs[yyi]]); - fprintf (stderr, " -> %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; @@ -883,10 +919,10 @@ yyreduce: if (yydebug) { short *yyssp1 = yyss - 1; - fprintf (stderr, "state stack now"); + YYFPRINTF (stderr, "state stack now"); while (yyssp1 != yyssp) - fprintf (stderr, " %d", *++yyssp1); - fprintf (stderr, "\n"); + YYFPRINTF (stderr, " %d", *++yyssp1); + YYFPRINTF (stderr, "\n"); } #endif @@ -901,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; @@ -964,7 +1000,7 @@ yyerrlab: yyerror ("parse error; also virtual memory exhausted"); } else -#endif /* defined (YYERROR_VERBOSE) */ +#endif /* YYERROR_VERBOSE */ yyerror ("parse error"); } goto yyerrlab1; @@ -1028,10 +1064,10 @@ yyerrpop: if (yydebug) { short *yyssp1 = yyss - 1; - fprintf (stderr, "Error: state stack now"); + YYFPRINTF (stderr, "Error: state stack now"); while (yyssp1 != yyssp) - fprintf (stderr, " %d", *++yyssp1); - fprintf (stderr, "\n"); + YYFPRINTF (stderr, " %d", *++yyssp1); + YYFPRINTF (stderr, "\n"); } #endif @@ -1102,4 +1138,4 @@ yyreturn: return yyresult; } -%%epilogue +%%{epilogue}