X-Git-Url: https://git.saurik.com/bison.git/blobdiff_plain/3fc16193d99d8ae347fa44d31edd884279d78310..24e0cbd0e11ecab72d40f1f51ab4b1450f8d145f:/data/yacc.c?ds=sidebyside diff --git a/data/yacc.c b/data/yacc.c index 840e7cec..40b1320b 100644 --- a/data/yacc.c +++ b/data/yacc.c @@ -506,27 +506,45 @@ while (0) #define YYERRCODE 256 -/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N]. */ +/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N]. + If N is 0, then set CURRENT to the empty location which ends + the previous symbol: RHS[0] (always defined). */ +#define YYRHSLOC(Rhs, K) ((Rhs)[K]) #ifndef YYLLOC_DEFAULT -# define YYLLOC_DEFAULT(Current, Rhs, N) \ - ((Current).first_line = (Rhs)[1].first_line, \ - (Current).first_column = (Rhs)[1].first_column, \ - (Current).last_line = (Rhs)[N].last_line, \ - (Current).last_column = (Rhs)[N].last_column) +# define YYLLOC_DEFAULT(Current, Rhs, N) \ + do \ + if (N) \ + { \ + (Current).first_line = YYRHSLOC(Rhs, 1).first_line; \ + (Current).first_column = YYRHSLOC(Rhs, 1).first_column; \ + (Current).last_line = YYRHSLOC(Rhs, N).last_line; \ + (Current).last_column = YYRHSLOC(Rhs, N).last_column; \ + } \ + else \ + { \ + (Current).first_line = (Current).last_line = \ + YYRHSLOC(Rhs, 0).last_line; \ + (Current).first_column = (Current).last_column = \ + YYRHSLOC(Rhs, 0).last_column; \ + } \ + while (0) +#endif + /* YY_LOCATION_PRINT -- Print the location on the stream. This macro was not mandated originally: define only if we know we won't break user code: when these are the locations we know. */ -# define YY_LOCATION_PRINT(File, Loc) \ - fprintf (File, "%d.%d-%d.%d", \ - (Loc).first_line, (Loc).first_column, \ - (Loc).last_line, (Loc).last_column) -#endif - #ifndef YY_LOCATION_PRINT -# define YY_LOCATION_PRINT(File, Loc) ((void) 0) +# if YYLTYPE_IS_TRIVIAL +# define YY_LOCATION_PRINT(File, Loc) \ + fprintf (File, "%d.%d-%d.%d", \ + (Loc).first_line, (Loc).first_column, \ + (Loc).last_line, (Loc).last_column) +# else +# define YY_LOCATION_PRINT(File, Loc) ((void) 0) +# endif #endif @@ -815,17 +833,26 @@ b4_c_function_def([yyparse], [int], b4_parse_param) yyssp = yyss; yyvsp = yyvs; -]b4_location_if([ yylsp = yyls;])[ -]m4_ifdef([b4_initial_action], [ -m4_pushdef([b4_at_dollar], [(*yylsp)])dnl -m4_pushdef([b4_dollar_dollar], [(*yyvsp)])dnl +]b4_location_if([[ yylsp = yyls; +#if YYLTYPE_IS_TRIVIAL + /* Initialize the default location before parsing starts. */ + yylloc.first_line = yylloc.last_line = 1; + yylloc.first_column = yylloc.last_column = 0; +#endif +]]) +m4_ifdef([b4_initial_action], [ +m4_pushdef([b4_at_dollar], [yylloc])dnl +m4_pushdef([b4_dollar_dollar], [yylval])dnl /* User initialization code. */ b4_initial_action m4_popdef([b4_dollar_dollar])dnl m4_popdef([b4_at_dollar])dnl /* Line __line__ of yacc.c. */ b4_syncline([@oline@], [@ofile@])])dnl - +[ + yyvsp[0] = yylval; +]b4_location_if([[ yylsp[0] = yylloc; +]]) [ goto yysetstate; /*------------------------------------------------------------. @@ -1008,8 +1035,8 @@ yyreduce: yyval = yyvsp[1-yylen]; ]b4_location_if( -[ /* Default location. */ - YYLLOC_DEFAULT (yyloc, yylsp - yylen, yylen);])[ +[[ /* Default location. */ + YYLLOC_DEFAULT (yyloc, yylsp - yylen, yylen);]])[ YY_REDUCE_PRINT (yyn); switch (yyn) ]{