X-Git-Url: https://git.saurik.com/bison.git/blobdiff_plain/f508cb0ac9a43d70b186255021420a27b3225f48..eeeb962b:/src/bison.simple diff --git a/src/bison.simple b/src/bison.simple index 2e44e86c..4a3ca508 100644 --- a/src/bison.simple +++ b/src/bison.simple @@ -44,8 +44,10 @@ #define yynerrs %%prefix##nerrs /* Copy the user declarations. */ +#line %%input_line "%%filename" %%prologue +#line %%line "%%skeleton" #ifndef __cplusplus # ifndef __STDC__ # define const @@ -96,10 +98,31 @@ # endif /* alloca not defined */ #endif /* YYSTACK_USE_ALLOCA not defined */ +#ifndef YYSTACK_USE_ALLOCA +# define YYSTACK_USE_ALLOCA 0 +#endif + +/* Realloc WHAT from SIZE to YYSTACKSIZE elements of TYPE. + If WHAT was malloc'ed (not the original automatic ARRAY), free it. */ #if YYSTACK_USE_ALLOCA -# define YYSTACK_ALLOC alloca +# define YYSTACK_REALLOC(Type, What, Array) \ +do { \ + Type *old = What; \ + What = (Type *) malloc (yystacksize * sizeof (Type)); \ + __yy_memcpy ((char *) What, (char *) old, \ + (size) * (unsigned int) sizeof (Type)); \ + yyfree_stacks = 1; \ + if (old != Array) \ + free (old); \ +} while (0) #else -# define YYSTACK_ALLOC malloc +# define YYSTACK_REALLOC(Type, What, Array) \ +do { \ + Type *old = What; \ + What = (Type *) alloca (yystacksize * sizeof (Type)); \ + __yy_memcpy ((char *) What, (char *) old, \ + (size) * (unsigned int) sizeof (Type)); \ +} while (0) #endif #define YYBISON 1 /* Identify Bison output. */ @@ -109,8 +132,10 @@ # define YYDEBUG %%debug #endif +#line %%input_line "%%filename" #ifndef YYSTYPE -# define YYSTYPE %%stype +typedef %%stype yystype; +# define YYSTYPE yystype #endif #ifndef YYLTYPE @@ -124,10 +149,6 @@ typedef struct yyltype # define YYLTYPE %%ltype #endif -#ifndef YYERROR_VERBOSE -# define YYERROR_VERBOSE %%verbose -#endif - /* Tokens. */ %%tokendef @@ -169,7 +190,7 @@ static const short yyrline[] = }; #endif -#if YYDEBUG || YYERROR_VERBOSE +#if %%error_verbose /* YYTNME[TOKEN_NUM] -- String name of the token TOKEN_NUM. */ static const char *const yytname[] = { @@ -444,7 +465,7 @@ yyparse (YYPARSE_PARAM_ARG) /* Three stacks and their tools: `yyss': related to states, - `yysv': related to semantic values, + `yyvs': related to semantic values, `yyls': related to locations. Refer to the stacks thru separate pointers, to allow yyoverflow @@ -509,51 +530,49 @@ yyparse (YYPARSE_PARAM_ARG) /*------------------------------------------------------------. | yynewstate -- Push a new state, which is found in yystate. | `------------------------------------------------------------*/ -yynewstate: + yynewstate: /* In all cases, when you get here, the value and location stacks have just been pushed. so pushing a state here evens the stacks. */ yyssp++; -yysetstate: + yysetstate: *yyssp = yystate; if (yyssp >= yyss + yystacksize - 1) { - /* Give user a chance to reallocate the stack. Use copies of - these so that the &'s don't force the real ones into memory. - */ - YYSTYPE *yyvs1 = yyvs; - short *yyss1 = yyss; -#if YYLSP_NEEDED - YYLTYPE *yyls1 = yyls; -#endif - /* Get the current used size of the three stacks, in elements. */ int size = yyssp - yyss + 1; #ifdef yyoverflow - /* Each stack pointer address is followed by the size of the - data in use in that stack, in bytes. */ + { + /* Give user a chance to reallocate the stack. Use copies of + these so that the &'s don't force the real ones into + memory. */ + YYSTYPE *yyvs1 = yyvs; + short *yyss1 = yyss; + + /* Each stack pointer address is followed by the size of the + data in use in that stack, in bytes. */ # if YYLSP_NEEDED - /* This used to be a conditional around just the two extra args, - but that might be undefined if yyoverflow is a macro. */ - yyoverflow ("parser stack overflow", - &yyss1, size * sizeof (*yyssp), - &yyvs1, size * sizeof (*yyvsp), - &yyls1, size * sizeof (*yylsp), - &yystacksize); + YYLTYPE *yyls1 = yyls; + /* This used to be a conditional around just the two extra args, + but that might be undefined if yyoverflow is a macro. */ + yyoverflow ("parser stack overflow", + &yyss1, size * sizeof (*yyssp), + &yyvs1, size * sizeof (*yyvsp), + &yyls1, size * sizeof (*yylsp), + &yystacksize); + yyls = yyls1; # else - yyoverflow ("parser stack overflow", - &yyss1, size * sizeof (*yyssp), - &yyvs1, size * sizeof (*yyvsp), - &yystacksize); -# endif - - yyss = yyss1; yyvs = yyvs1; -# if YYLSP_NEEDED - yyls = yyls1; + yyoverflow ("parser stack overflow", + &yyss1, size * sizeof (*yyssp), + &yyvs1, size * sizeof (*yyvsp), + &yystacksize); # endif + yyss = yyss1; + yyvs = yyvs1; + } #else /* no yyoverflow */ /* Extend the stack our own way. */ if (yystacksize >= YYMAXDEPTH) @@ -572,19 +591,11 @@ yysetstate: yystacksize *= 2; if (yystacksize > YYMAXDEPTH) yystacksize = YYMAXDEPTH; -# if !YYSTACK_USE_ALLOCA - yyfree_stacks = 1; -# endif - yyss = (short *) YYSTACK_ALLOC (yystacksize * sizeof (*yyssp)); - __yy_memcpy ((char *)yyss, (char *)yyss1, - size * (unsigned int) sizeof (*yyssp)); - yyvs = (YYSTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yyvsp)); - __yy_memcpy ((char *)yyvs, (char *)yyvs1, - size * (unsigned int) sizeof (*yyvsp)); + + YYSTACK_REALLOC (short, yyss, yyssa); + YYSTACK_REALLOC (YYSTYPE, yyvs, yyvsa); # if YYLSP_NEEDED - yyls = (YYLTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yylsp)); - __yy_memcpy ((char *)yyls, (char *)yyls1, - size * (unsigned int) sizeof (*yylsp)); + YYSTACK_REALLOC (YYLTYPE, yyls, yylsa); # endif #endif /* no yyoverflow */ @@ -758,7 +769,7 @@ yyreduce: #endif switch (yyn) { - %%action /* The action file replaces this line. */ + %%action } #line %%line "%%skeleton" @@ -808,7 +819,7 @@ yyerrlab: { ++yynerrs; -#if YYERROR_VERBOSE +#if %%error_verbose yyn = yypact[yystate]; if (yyn > YYFLAG && yyn < YYLAST) @@ -818,30 +829,29 @@ yyerrlab: int x, count; count = 0; - /* Start X at -yyn if nec to avoid negative indexes in yycheck. */ - for (x = (yyn < 0 ? -yyn : 0); + /* Start X at -YYN if negative to avoid negative indexes in + YYCHECK. */ + for (x = yyn < 0 ? -yyn : 0; x < (int) (sizeof (yytname) / sizeof (char *)); x++) if (yycheck[x + yyn] == x) size += strlen (yytname[x]) + 15, count++; - size += strlen ("parse error, unexpected `") + 1; + size += strlen ("parse error, unexpected ") + 1; size += strlen (yytname[YYTRANSLATE (yychar)]); msg = (char *) malloc (size); if (msg != 0) { - strcpy (msg, "parse error, unexpected `"); + strcpy (msg, "parse error, unexpected "); strcat (msg, yytname[YYTRANSLATE (yychar)]); - strcat (msg, "'"); if (count < 5) { count = 0; - for (x = (yyn < 0 ? -yyn : 0); + for (x = yyn < 0 ? -yyn : 0; x < (int) (sizeof (yytname) / sizeof (char *)); x++) if (yycheck[x + yyn] == x) { - strcat (msg, count == 0 ? ", expecting `" : " or `"); + strcat (msg, count == 0 ? ", expecting " : " or "); strcat (msg, yytname[x]); - strcat (msg, "'"); count++; } } @@ -849,10 +859,10 @@ yyerrlab: free (msg); } else - yyerror ("parse error; also virtual memory exceeded"); + yyerror ("parse error; also virtual memory exhausted"); } else -#endif /* YYERROR_VERBOSE */ +#endif /* %%ERROR_VERBOSE */ yyerror ("parse error"); } goto yyerrlab1; @@ -990,5 +1000,5 @@ yyabortlab: return 1; } +#line %%input_line "%%filename" %%epilogue -