mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-21 18:23:03 +00:00
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.
This commit is contained in:
14
ChangeLog
14
ChangeLog
@@ -1,3 +1,17 @@
|
|||||||
|
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>
|
2006-12-20 Joel E. Denny <jdenny@ces.clemson.edu>
|
||||||
|
|
||||||
Fix bug such that the first pushed token's value and location are
|
Fix bug such that the first pushed token's value and location are
|
||||||
|
|||||||
49
data/push.c
49
data/push.c
@@ -994,22 +994,22 @@ int yychar;
|
|||||||
|
|
||||||
/* The semantic value of the lookahead symbol. */
|
/* The semantic value of the lookahead symbol. */
|
||||||
YYSTYPE yylval;
|
YYSTYPE yylval;
|
||||||
|
]b4_locations_if([[
|
||||||
/* Number of syntax errors so far. */
|
|
||||||
]b4_push_if([],[
|
|
||||||
int yynerrs;])b4_locations_if([[
|
|
||||||
/* Location data for the lookahead symbol. */
|
/* Location data for the lookahead symbol. */
|
||||||
YYLTYPE yylloc;]])
|
YYLTYPE yylloc;
|
||||||
])
|
]])b4_pure_if([], [[
|
||||||
|
/* Number of syntax errors so far. */
|
||||||
m4_define([b4_yyerror_range],b4_push_if([yyps->yyerror_range],[yyerror_range]))
|
int yynerrs;
|
||||||
|
]])])
|
||||||
|
|
||||||
# b4_declare_parser_state_variables
|
# b4_declare_parser_state_variables
|
||||||
# ---------------------------------
|
# ---------------------------------
|
||||||
# Declare all the variables that are needed to maintain the parser state
|
# Declare all the variables that are needed to maintain the parser state
|
||||||
# between calls to yypush_parse.
|
# between calls to yypush_parse.
|
||||||
m4_define([b4_declare_parser_state_variables],
|
m4_define([b4_declare_parser_state_variables],
|
||||||
[[
|
[b4_pure_if([[ /* Number of syntax errors so far. */
|
||||||
|
int yynerrs;
|
||||||
|
]])[
|
||||||
int yystate;
|
int yystate;
|
||||||
int yyn;
|
int yyn;
|
||||||
int yyresult;
|
int yyresult;
|
||||||
@@ -1040,13 +1040,16 @@ m4_define([b4_declare_parser_state_variables],
|
|||||||
YYLTYPE yylsa[YYINITDEPTH];
|
YYLTYPE yylsa[YYINITDEPTH];
|
||||||
YYLTYPE *yyls;
|
YYLTYPE *yyls;
|
||||||
YYLTYPE *yylsp;
|
YYLTYPE *yylsp;
|
||||||
|
|
||||||
/* The locations where the error started and ended. */
|
/* The locations where the error started and ended. */
|
||||||
YYLTYPE yyerror_range[2];]])[
|
YYLTYPE yyerror_range[2];
|
||||||
|
]])[
|
||||||
YYSIZE_T yystacksize;
|
YYSIZE_T yystacksize;
|
||||||
|
|
||||||
/* The variables used to return semantic value and location from the
|
/* The variables used to return semantic value and location from the
|
||||||
action routines. */
|
action routines. */
|
||||||
YYSTYPE yyval;
|
YYSTYPE yyval;
|
||||||
]b4_locations_if([[ YYLTYPE yyloc;
|
]b4_locations_if([[ YYLTYPE yyloc;
|
||||||
]])])
|
]])])
|
||||||
|
|
||||||
m4_divert_pop([KILL])dnl# ====================== End of M4 code.
|
m4_divert_pop([KILL])dnl# ====================== End of M4 code.
|
||||||
@@ -1077,7 +1080,8 @@ b4_push_if(
|
|||||||
free (yyps);
|
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 yyn yyps->yyn
|
||||||
#define yyresult yyps->yyresult
|
#define yyresult yyps->yyresult
|
||||||
#define yyerrstatus yyps->yyerrstatus
|
#define yyerrstatus yyps->yyerrstatus
|
||||||
@@ -1091,6 +1095,7 @@ b4_push_if(
|
|||||||
]b4_locations_if([[#define yylsa yyps->yylsa
|
]b4_locations_if([[#define yylsa yyps->yylsa
|
||||||
#define yyls yyps->yyls
|
#define yyls yyps->yyls
|
||||||
#define yylsp yyps->yylsp
|
#define yylsp yyps->yylsp
|
||||||
|
#define yyerror_range yyps->yyerror_range
|
||||||
]])[#define yystacksize yyps->yystacksize
|
]])[#define yystacksize yyps->yystacksize
|
||||||
#define yyval yyps->yyval
|
#define yyval yyps->yyval
|
||||||
]b4_locations_if([[#define yyloc yyps->yyloc
|
]b4_locations_if([[#define yyloc yyps->yyloc
|
||||||
@@ -1142,7 +1147,7 @@ b4_c_function_def([yyparse], [int], b4_parse_param)
|
|||||||
|
|
||||||
yystate = 0;
|
yystate = 0;
|
||||||
yyerrstatus = 0;
|
yyerrstatus = 0;
|
||||||
]b4_push_if([], [[ yynerrs = 0;]])[
|
yynerrs = 0;
|
||||||
yychar = YYEMPTY; /* Cause a token to be read. */
|
yychar = YYEMPTY; /* Cause a token to be read. */
|
||||||
|
|
||||||
/* Initialize stack pointers.
|
/* Initialize stack pointers.
|
||||||
@@ -1401,7 +1406,7 @@ yyerrlab:
|
|||||||
/* If not already recovering from an error, report this error. */
|
/* If not already recovering from an error, report this error. */
|
||||||
if (!yyerrstatus)
|
if (!yyerrstatus)
|
||||||
{
|
{
|
||||||
]b4_push_if([],[ ++yynerrs;])[
|
++yynerrs;
|
||||||
#if ! YYERROR_VERBOSE
|
#if ! YYERROR_VERBOSE
|
||||||
yyerror (]b4_yyerror_args[YY_("syntax error"));
|
yyerror (]b4_yyerror_args[YY_("syntax error"));
|
||||||
#else
|
#else
|
||||||
@@ -1439,7 +1444,7 @@ yyerrlab:
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
]b4_locations_if([[ ]b4_yyerror_range[[0] = yylloc;]])[
|
]b4_locations_if([[ yyerror_range[0] = yylloc;]])[
|
||||||
|
|
||||||
if (yyerrstatus == 3)
|
if (yyerrstatus == 3)
|
||||||
{
|
{
|
||||||
@@ -1476,7 +1481,7 @@ yyerrorlab:
|
|||||||
if (/*CONSTCOND*/ 0)
|
if (/*CONSTCOND*/ 0)
|
||||||
goto yyerrorlab;
|
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
|
]])[ /* Do not reclaim the symbols of the rule which action triggered
|
||||||
this YYERROR. */
|
this YYERROR. */
|
||||||
YYPOPSTACK (yylen);
|
YYPOPSTACK (yylen);
|
||||||
@@ -1510,7 +1515,7 @@ yyerrlab1:
|
|||||||
if (yyssp == yyss)
|
if (yyssp == yyss)
|
||||||
YYABORT;
|
YYABORT;
|
||||||
|
|
||||||
]b4_locations_if([[ ]b4_yyerror_range[[0] = *yylsp;]])[
|
]b4_locations_if([[ yyerror_range[0] = *yylsp;]])[
|
||||||
yydestruct ("Error: popping",
|
yydestruct ("Error: popping",
|
||||||
yystos[yystate], yyvsp]b4_locations_if([, yylsp])[]b4_user_args[);
|
yystos[yystate], yyvsp]b4_locations_if([, yylsp])[]b4_user_args[);
|
||||||
YYPOPSTACK (1);
|
YYPOPSTACK (1);
|
||||||
@@ -1520,10 +1525,10 @@ yyerrlab1:
|
|||||||
|
|
||||||
*++yyvsp = yylval;
|
*++yyvsp = yylval;
|
||||||
]b4_locations_if([[
|
]b4_locations_if([[
|
||||||
]b4_yyerror_range[[1] = yylloc;
|
yyerror_range[1] = yylloc;
|
||||||
/* Using YYLLOC is tempting, but would change the location of
|
/* Using YYLLOC is tempting, but would change the location of
|
||||||
the lookahead. YYLOC is available though. */
|
the lookahead. YYLOC is available though. */
|
||||||
YYLLOC_DEFAULT (yyloc, (]b4_yyerror_range[- 1), 2);
|
YYLLOC_DEFAULT (yyloc, (yyerror_range - 1), 2);
|
||||||
*++yylsp = yyloc;]])[
|
*++yylsp = yyloc;]])[
|
||||||
|
|
||||||
/* Shift the error token. */
|
/* Shift the error token. */
|
||||||
@@ -1609,8 +1614,7 @@ b4_token_enums_defines(b4_tokens)
|
|||||||
# define YYSTYPE_IS_DECLARED 1
|
# define YYSTYPE_IS_DECLARED 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
]b4_pure_if([],
|
]b4_pure_if([], [[extern YYSTYPE ]b4_prefix[lval;]])
|
||||||
[extern YYSTYPE b4_prefix[]lval;])
|
|
||||||
|
|
||||||
b4_locations_if(
|
b4_locations_if(
|
||||||
[#if ! defined YYLTYPE && ! defined YYLTYPE_IS_DECLARED
|
[#if ! defined YYLTYPE && ! defined YYLTYPE_IS_DECLARED
|
||||||
@@ -1626,8 +1630,7 @@ typedef struct YYLTYPE
|
|||||||
# define YYLTYPE_IS_TRIVIAL 1
|
# define YYLTYPE_IS_TRIVIAL 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
]b4_pure_if([],
|
]b4_pure_if([], [[extern YYLTYPE ]b4_prefix[lloc;]])
|
||||||
[extern YYLTYPE b4_prefix[]lloc;])
|
|
||||||
)dnl b4_locations_if
|
)dnl b4_locations_if
|
||||||
|
|
||||||
b4_push_if([[#ifndef YYPUSH_DECLS
|
b4_push_if([[#ifndef YYPUSH_DECLS
|
||||||
|
|||||||
Reference in New Issue
Block a user