Fix %error-verbose for conflicts resolved by %nonassoc.

* NEWS (2.5): Document.
* data/glr.c (yyreportSyntaxError): Fix this by checking
yyis_table_ninf.
* data/yacc.c (yysyntax_error): Likewise.
* data/lalr1.cc (yysyntax_error_): Fix this by checking
yytable_ninf_.
* data/lalr1.java (yysyntax_error): Likewise.
* tests/conflicts.at (%nonassoc and eof): Update expected output
and remove FIXME.
(cherry picked from commit 53f036ce02)

Conflicts:

	data/lalr1.cc
	data/lalr1.java
	src/parse-gram.c
	src/parse-gram.h
This commit is contained in:
Joel E. Denny
2009-08-25 01:13:02 -04:00
parent 77373efad2
commit 1fa303077d
9 changed files with 139 additions and 113 deletions

View File

@@ -2128,7 +2128,8 @@ yyreportSyntaxError (yyGLRStack* yystackp]b4_user_formals[)
yyfmt = yystpcpy (yyformat, yyunexpected);
for (yyx = yyxbegin; yyx < yyxend; ++yyx)
if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR
&& !yyis_table_ninf (yytable[yyx + yyn]))
{
if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
{

View File

@@ -850,7 +850,8 @@ b4_error_verbose_if([, int tok])[)
int yyxend = yychecklim < yyntokens_ ? yychecklim : yyntokens_;
int count = 0;
for (int x = yyxbegin; x < yyxend; ++x)
if (yycheck_[x + yyn] == x && x != yyterror_)
if (yycheck_[x + yyn] == x && x != yyterror_
&& yytable_[x + yyn] != yytable_ninf_)
++count;
// FIXME: This method of building the message is not compatible
@@ -867,7 +868,8 @@ b4_error_verbose_if([, int tok])[)
{
count = 0;
for (int x = yyxbegin; x < yyxend; ++x)
if (yycheck_[x + yyn] == x && x != yyterror_)
if (yycheck_[x + yyn] == x && x != yyterror_
&& yytable_[x + yyn] != yytable_ninf_)
{
res += (!count++) ? ", expecting " : " or ";
res += yytnamerr_ (yytname_[x]);

View File

@@ -700,7 +700,8 @@ m4_popdef([b4_at_dollar])])dnl
int yyxend = yychecklim < yyntokens_ ? yychecklim : yyntokens_;
int count = 0;
for (int x = yyxbegin; x < yyxend; ++x)
if (yycheck_[x + yyn] == x && x != yyterror_)
if (yycheck_[x + yyn] == x && x != yyterror_
&& yycheck_[x + yyn] != yytable_ninf_)
++count;
// FIXME: This method of building the message is not compatible
@@ -711,7 +712,8 @@ m4_popdef([b4_at_dollar])])dnl
{
count = 0;
for (int x = yyxbegin; x < yyxend; ++x)
if (yycheck_[x + yyn] == x && x != yyterror_)
if (yycheck_[x + yyn] == x && x != yyterror_
&& yycheck_[x + yyn] != yytable_ninf_)
{
res.append (count++ == 0 ? ", expecting " : " or ");
res.append (yytnamerr_ (yytname_[x]));

View File

@@ -953,7 +953,8 @@ yysyntax_error (char *yyresult, int yystate, int yychar)
yyfmt = yystpcpy (yyformat, yyunexpected);
for (yyx = yyxbegin; yyx < yyxend; ++yyx)
if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR
&& !yyis_table_ninf (yytable[yyx + yyn]))
{
if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
{