mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-14 23:03:04 +00:00
More fixes related to last two patches.
* data/bison.m4 (b4_integral_parser_tables_map): Fix YYTABLE comments: zero indicates syntax error not default action. * data/c.m4 (b4_table_value_equals): Comment that YYID must be defined. * data/glr.c (yyis_pact_ninf): Rename to... (yypact_value_is_default): ... this. (yyisDefaultedState): Update for rename. (yyis_table_ninf): Rename to... (yytable_value_is_error): ... this, and check for value zero besides just YYTABLE_NINF. (yygetLRActions): Check for default value from yypact. It appears that this check is always performed before this function is invoked, and so adding the check here is probably redundant. However, the code may evolve after this subtlety is forgotten. Also, update for rename to yytable_value_is_error. Because that macro now checks for zero, a different but equivalent branch of the if-then-else here is evaluated. (yyreportSyntaxError): Update for rename to yytable_value_is_error. The zero condition was mishandled before. (yyrecoverSyntaxError): Update for renames. No behavioral changes. * data/lalr1.cc, data/lalr1.java (yy_pact_value_is_default_): New function. (yy_table_value_is_error_): New function. (parse): Use new functions where possible. No behavioral changes. (yysyntax_error_, yysyntax_error): Use yy_table_value_is_error_. The zero condition was mishandled before. * data/yacc.c (yyis_pact_ninf): Rename to... (yypact_value_is_default): ... this. (yyis_table_ninf): Rename to... (yytable_value_is_error): ... this, and check for value zero besides just YYTABLE_NINF. (yysyntax_error): Update for rename to yytable_value_is_error. The zero condition was mishandled before. (yyparse): Update for renames. No behavioral changes. * src/tables.h: Improve comments about yypact, yytable, etc. more. Most importantly, say yytable value of zero means syntax error not default action.
This commit is contained in:
@@ -245,6 +245,14 @@ do { \
|
||||
/// \param yylhs the nonterminal to push on the stack
|
||||
state_type yy_lr_goto_state_ (state_type yystate, int yylhs);
|
||||
|
||||
/// Whether the given \c yypact_ value indicates a defaulted state.
|
||||
/// \param yyvalue the value to check
|
||||
static bool yy_pact_value_is_default_ (int yyvalue);
|
||||
|
||||
/// Whether the given \c yytable_ value indicates a syntax error.
|
||||
/// \param yyvalue the value to check
|
||||
static bool yy_table_value_is_error_ (int yyvalue);
|
||||
|
||||
/// Internal symbol numbers.
|
||||
typedef ]b4_int_type_for([b4_translate])[ token_number_type;
|
||||
static const ]b4_int_type(b4_pact_ninf, b4_pact_ninf)[ yypact_ninf_;
|
||||
@@ -651,6 +659,18 @@ b4_percent_code_get[]dnl
|
||||
return yydefgoto_[yylhs - yyntokens_];
|
||||
}
|
||||
|
||||
inline bool
|
||||
]b4_parser_class_name[::yy_pact_value_is_default_ (int yyvalue)
|
||||
{
|
||||
return yyvalue == yypact_ninf_;
|
||||
}
|
||||
|
||||
inline bool
|
||||
]b4_parser_class_name[::yy_table_value_is_error_ (int yyvalue)
|
||||
{
|
||||
return yyvalue == 0 || yyvalue == yytable_ninf_;
|
||||
}
|
||||
|
||||
int
|
||||
]b4_parser_class_name[::parse ()
|
||||
{
|
||||
@@ -709,7 +729,7 @@ m4_popdef([b4_at_dollar])])dnl
|
||||
|
||||
/* Try to take a decision without lookahead. */
|
||||
yyn = yypact_[yystack_[0].state];
|
||||
if (yyn == yypact_ninf_)
|
||||
if (yy_pact_value_is_default_ (yyn))
|
||||
goto yydefault;
|
||||
|
||||
/* Read a lookahead token. */
|
||||
@@ -737,7 +757,7 @@ m4_ifdef([b4_lex_param], [, ]b4_lex_param)));])[
|
||||
yyn = yytable_[yyn];
|
||||
if (yyn <= 0)
|
||||
{
|
||||
if (yyn == 0 || yyn == yytable_ninf_)
|
||||
if (yy_table_value_is_error_ (yyn))
|
||||
goto yyerrlab;
|
||||
yyn = -yyn;
|
||||
goto yyreduce;
|
||||
@@ -887,7 +907,7 @@ m4_ifdef([b4_lex_param], [, ]b4_lex_param)));])[
|
||||
for (;;)
|
||||
{
|
||||
yyn = yypact_[yystack_[0].state];
|
||||
if (yyn != yypact_ninf_)
|
||||
if (!yy_pact_value_is_default_ (yyn))
|
||||
{
|
||||
yyn += yyterror_;
|
||||
if (0 <= yyn && yyn <= yylast_ && yycheck_[yyn] == yyterror_)
|
||||
@@ -972,7 +992,7 @@ b4_error_verbose_if([state_type yystate, int yytoken],
|
||||
yyarg[yycount++] = yytname_[yytoken];
|
||||
for (int yyx = yyxbegin; yyx < yyxend; ++yyx)
|
||||
if (yycheck_[yyx + yyn] == yyx && yyx != yyterror_
|
||||
&& yytable_[yyx + yyn] != yytable_ninf_)
|
||||
&& !yy_table_value_is_error_ (yytable_[yyx + yyn]))
|
||||
{
|
||||
if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user