mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-09 20:33:03 +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:
@@ -533,7 +533,7 @@ m4_popdef([b4_at_dollar])])dnl
|
||||
|
||||
/* Take a decision. First try without lookahead. */
|
||||
yyn = yypact_[yystate];
|
||||
if (yyn == yypact_ninf_)
|
||||
if (yy_pact_value_is_default_ (yyn))
|
||||
{
|
||||
label = YYDEFAULT;
|
||||
break;
|
||||
@@ -572,7 +572,7 @@ m4_popdef([b4_at_dollar])])dnl
|
||||
/* <= 0 means reduce or error. */
|
||||
else if ((yyn = yytable_[yyn]) <= 0)
|
||||
{
|
||||
if (yyn == 0 || yyn == yytable_ninf_)
|
||||
if (yy_table_value_is_error_ (yyn))
|
||||
label = YYFAIL;
|
||||
else
|
||||
{
|
||||
@@ -676,7 +676,7 @@ m4_popdef([b4_at_dollar])])dnl
|
||||
for (;;)
|
||||
{
|
||||
yyn = yypact_[yystate];
|
||||
if (yyn != yypact_ninf_)
|
||||
if (!yy_pact_value_is_default_ (yyn))
|
||||
{
|
||||
yyn += yyterror_;
|
||||
if (0 <= yyn && yyn <= yylast_ && yycheck_[yyn] == yyterror_)
|
||||
@@ -745,7 +745,7 @@ m4_popdef([b4_at_dollar])])dnl
|
||||
int count = 0;
|
||||
for (int x = yyxbegin; x < yyxend; ++x)
|
||||
if (yycheck_[x + yyn] == x && x != yyterror_
|
||||
&& yycheck_[x + yyn] != yytable_ninf_)
|
||||
&& !yy_table_value_is_error_ (yycheck_[x + yyn]))
|
||||
++count;
|
||||
|
||||
// FIXME: This method of building the message is not compatible
|
||||
@@ -757,7 +757,7 @@ m4_popdef([b4_at_dollar])])dnl
|
||||
count = 0;
|
||||
for (int x = yyxbegin; x < yyxend; ++x)
|
||||
if (yycheck_[x + yyn] == x && x != yyterror_
|
||||
&& yycheck_[x + yyn] != yytable_ninf_)
|
||||
&& !yy_table_value_is_error_ (yycheck_[x + yyn]))
|
||||
{
|
||||
res.append (count++ == 0 ? ", expecting " : " or ");
|
||||
res.append (yytnamerr_ (yytname_[x]));
|
||||
@@ -770,6 +770,24 @@ m4_popdef([b4_at_dollar])])dnl
|
||||
return "syntax error";
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether the given <code>yypact_</code> value indicates a defaulted state.
|
||||
* @@param yyvalue the value to check
|
||||
*/
|
||||
private static boolean yy_pact_value_is_default_ (int yyvalue)
|
||||
{
|
||||
return yyvalue == yypact_ninf_;
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether the given <code>yytable_</code> value indicates a syntax error.
|
||||
* @@param yyvalue the value to check
|
||||
*/
|
||||
private static boolean yy_table_value_is_error_ (int yyvalue)
|
||||
{
|
||||
return yyvalue == 0 || yyvalue == yytable_ninf_;
|
||||
}
|
||||
|
||||
private static final ]b4_int_type_for([b4_pact])[ yypact_ninf_ = ]b4_pact_ninf[;
|
||||
private static final ]b4_int_type_for([b4_table])[ yytable_ninf_ = ]b4_table_ninf[;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user