mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-14 23:03:04 +00:00
Let the initial-action act on the look-ahead, and use it for the
"initial push" (corresponding to an hypothetical beginning-of-file). And let lalr1.cc honor %initial-action. * doc/bison.texinfo (Initial Action Decl): Clarify, and add an example. * data/lalr1.cc (Parser::initlocation_): Remove, bad experiment. (Parser::Parser): Remove the ctor that used to initialize it. (Parser::parse): Like in the other skeletons, issue the "starting parse" message before any action. Honor %initial-action. Initialize the stacks with the lookahead. * data/yacc.c: Let $$ and @$ in %initial-action designate the look-ahead. Push them in the stacks. * tests/actions.at, tests/calc.at: Adjust the C++ ctor invocations.
This commit is contained in:
13
data/yacc.c
13
data/yacc.c
@@ -821,20 +821,23 @@ b4_c_function_def([yyparse], [int], b4_parse_param)
|
||||
]b4_location_if([[ yylsp = yyls;
|
||||
#if YYLTYPE_IS_TRIVIAL
|
||||
/* Initialize the default location before parsing starts. */
|
||||
yyls[0].first_line = yyls[0].last_line = 1;
|
||||
yyls[0].first_column = yyls[0].last_column = 0;
|
||||
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], [(*yylsp)])dnl
|
||||
m4_pushdef([b4_dollar_dollar], [(*yyvsp)])dnl
|
||||
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;
|
||||
|
||||
/*------------------------------------------------------------.
|
||||
|
||||
Reference in New Issue
Block a user