mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-16 07:43:03 +00:00
More fixes related to last two patches.
* data/c.m4 (b4_table_value_equals): Comment that YYID must be
defined.
* data/glr.c, data/lalr1.cc, data/lalr1.java, data/yacc.c: Fix
yytable comments: zero indicates syntax error not default
action.
* 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.
(cherry picked from commit f2b30bdf37)
Conflicts:
data/bison.m4
data/lalr1.cc
data/lalr1.java
data/yacc.c
src/parse-gram.c
src/parse-gram.h
This commit is contained in:
@@ -190,6 +190,14 @@ b4_error_verbose_if([, int tok])[);
|
||||
/// The location stack.
|
||||
location_stack_type yylocation_stack_;
|
||||
|
||||
/// 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;
|
||||
/* Tables. */
|
||||
@@ -518,6 +526,18 @@ do { \
|
||||
}
|
||||
#endif
|
||||
|
||||
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 ()
|
||||
{
|
||||
@@ -584,7 +604,7 @@ m4_popdef([b4_at_dollar])])dnl
|
||||
|
||||
/* Try to take a decision without lookahead. */
|
||||
yyn = yypact_[yystate];
|
||||
if (yyn == yypact_ninf_)
|
||||
if (yy_pact_value_is_default_ (yyn))
|
||||
goto yydefault;
|
||||
|
||||
/* Read a lookahead token. */
|
||||
@@ -620,8 +640,8 @@ m4_ifdef([b4_lex_param], [, ]b4_lex_param))[;
|
||||
yyn = yytable_[yyn];
|
||||
if (yyn <= 0)
|
||||
{
|
||||
if (yyn == 0 || yyn == yytable_ninf_)
|
||||
goto yyerrlab;
|
||||
if (yy_table_value_is_error_ (yyn))
|
||||
goto yyerrlab;
|
||||
yyn = -yyn;
|
||||
goto yyreduce;
|
||||
}
|
||||
@@ -762,7 +782,7 @@ b4_error_verbose_if([, yytoken])[));
|
||||
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_)
|
||||
@@ -851,7 +871,7 @@ b4_error_verbose_if([, int tok])[)
|
||||
int count = 0;
|
||||
for (int x = yyxbegin; x < yyxend; ++x)
|
||||
if (yycheck_[x + yyn] == x && x != yyterror_
|
||||
&& yytable_[x + yyn] != yytable_ninf_)
|
||||
&& !yy_table_value_is_error_ (yytable_[x + yyn]))
|
||||
++count;
|
||||
|
||||
// FIXME: This method of building the message is not compatible
|
||||
@@ -869,7 +889,7 @@ b4_error_verbose_if([, int tok])[)
|
||||
count = 0;
|
||||
for (int x = yyxbegin; x < yyxend; ++x)
|
||||
if (yycheck_[x + yyn] == x && x != yyterror_
|
||||
&& yytable_[x + yyn] != yytable_ninf_)
|
||||
&& !yy_table_value_is_error_ (yytable_[x + yyn]))
|
||||
{
|
||||
res += (!count++) ? ", expecting " : " or ";
|
||||
res += yytnamerr_ (yytname_[x]);
|
||||
@@ -917,7 +937,8 @@ b4_error_verbose_if([, int tok])[)
|
||||
|
||||
/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
|
||||
positive, shift that token. If negative, reduce the rule which
|
||||
number is the opposite. If zero, do what YYDEFACT says. */
|
||||
number is the opposite. If zero or YYTABLE_NINF_, syntax
|
||||
error. */
|
||||
const ]b4_int_type(b4_table_ninf, b4_table_ninf) b4_parser_class_name::yytable_ninf_ = b4_table_ninf[;
|
||||
const ]b4_int_type_for([b4_table])[
|
||||
]b4_parser_class_name[::yytable_[] =
|
||||
|
||||
Reference in New Issue
Block a user