+2006-12-20 Joel E. Denny <jdenny@ces.clemson.edu>
+
+ Remove some unnecessary differences between the pull parser code and
+ the push parser code. This patch enables yynerrs in push mode.
+ * data/push.c: Reformat M4 a little.
+ (b4_yyerror_range): Remove and convert all uses to just yyerror_range.
+ (b4_declare_scanner_communication_variables): Don't omit yynerrs just
+ because push mode is on. Instead, if pure mode is on, move yynerrs
+ to...
+ (b4_declare_parser_state_variables): ... here.
+ (yynerrs, yyerror_range): For push mode, #define each NAME in this list
+ to yyps->NAME so it can be used in yypush_parse.
+ (yypush_parse): Don't omit uses of yynerrs in push mode.
+
2006-12-20 Joel E. Denny <jdenny@ces.clemson.edu>
Fix bug such that the first pushed token's value and location are
/* The semantic value of the lookahead symbol. */
YYSTYPE yylval;
-
-/* Number of syntax errors so far. */
-]b4_push_if([],[
-int yynerrs;])b4_locations_if([[
+]b4_locations_if([[
/* Location data for the lookahead symbol. */
-YYLTYPE yylloc;]])
-])
-
-m4_define([b4_yyerror_range],b4_push_if([yyps->yyerror_range],[yyerror_range]))
+YYLTYPE yylloc;
+]])b4_pure_if([], [[
+/* Number of syntax errors so far. */
+int yynerrs;
+]])])
# b4_declare_parser_state_variables
# ---------------------------------
# Declare all the variables that are needed to maintain the parser state
# between calls to yypush_parse.
m4_define([b4_declare_parser_state_variables],
-[[
+[b4_pure_if([[ /* Number of syntax errors so far. */
+ int yynerrs;
+]])[
int yystate;
int yyn;
int yyresult;
YYLTYPE yylsa[YYINITDEPTH];
YYLTYPE *yyls;
YYLTYPE *yylsp;
+
/* The locations where the error started and ended. */
- YYLTYPE yyerror_range[2];]])[
+ YYLTYPE yyerror_range[2];
+]])[
YYSIZE_T yystacksize;
+
/* The variables used to return semantic value and location from the
action routines. */
YYSTYPE yyval;
-]b4_locations_if([[ YYLTYPE yyloc;
+]b4_locations_if([[ YYLTYPE yyloc;
]])])
m4_divert_pop([KILL])dnl# ====================== End of M4 code.
free (yyps);
}
-#define yystate yyps->yystate
+]b4_pure_if([[#define ]b4_prefix[nerrs yyps->]b4_prefix[nerrs
+]])[#define yystate yyps->yystate
#define yyn yyps->yyn
#define yyresult yyps->yyresult
#define yyerrstatus yyps->yyerrstatus
]b4_locations_if([[#define yylsa yyps->yylsa
#define yyls yyps->yyls
#define yylsp yyps->yylsp
+#define yyerror_range yyps->yyerror_range
]])[#define yystacksize yyps->yystacksize
#define yyval yyps->yyval
]b4_locations_if([[#define yyloc yyps->yyloc
yystate = 0;
yyerrstatus = 0;
-]b4_push_if([], [[ yynerrs = 0;]])[
+ yynerrs = 0;
yychar = YYEMPTY; /* Cause a token to be read. */
/* Initialize stack pointers.
/* If not already recovering from an error, report this error. */
if (!yyerrstatus)
{
-]b4_push_if([],[ ++yynerrs;])[
+ ++yynerrs;
#if ! YYERROR_VERBOSE
yyerror (]b4_yyerror_args[YY_("syntax error"));
#else
#endif
}
-]b4_locations_if([[ ]b4_yyerror_range[[0] = yylloc;]])[
+]b4_locations_if([[ yyerror_range[0] = yylloc;]])[
if (yyerrstatus == 3)
{
if (/*CONSTCOND*/ 0)
goto yyerrorlab;
-]b4_locations_if([[ ]b4_yyerror_range[[0] = yylsp[1-yylen];
+]b4_locations_if([[ yyerror_range[0] = yylsp[1-yylen];
]])[ /* Do not reclaim the symbols of the rule which action triggered
this YYERROR. */
YYPOPSTACK (yylen);
if (yyssp == yyss)
YYABORT;
-]b4_locations_if([[ ]b4_yyerror_range[[0] = *yylsp;]])[
+]b4_locations_if([[ yyerror_range[0] = *yylsp;]])[
yydestruct ("Error: popping",
yystos[yystate], yyvsp]b4_locations_if([, yylsp])[]b4_user_args[);
YYPOPSTACK (1);
*++yyvsp = yylval;
]b4_locations_if([[
- ]b4_yyerror_range[[1] = yylloc;
+ yyerror_range[1] = yylloc;
/* Using YYLLOC is tempting, but would change the location of
the lookahead. YYLOC is available though. */
- YYLLOC_DEFAULT (yyloc, (]b4_yyerror_range[- 1), 2);
+ YYLLOC_DEFAULT (yyloc, (yyerror_range - 1), 2);
*++yylsp = yyloc;]])[
/* Shift the error token. */
# define YYSTYPE_IS_DECLARED 1
#endif
-]b4_pure_if([],
-[extern YYSTYPE b4_prefix[]lval;])
+]b4_pure_if([], [[extern YYSTYPE ]b4_prefix[lval;]])
b4_locations_if(
[#if ! defined YYLTYPE && ! defined YYLTYPE_IS_DECLARED
# define YYLTYPE_IS_TRIVIAL 1
#endif
-]b4_pure_if([],
- [extern YYLTYPE b4_prefix[]lloc;])
+]b4_pure_if([], [[extern YYLTYPE ]b4_prefix[lloc;]])
)dnl b4_locations_if
b4_push_if([[#ifndef YYPUSH_DECLS