mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-16 07:43:03 +00:00
* data/yacc.c, data/glr.c, data/lal1.cc: Use similar code to
generate verbose error messages. Use the number of tokens as an upper bound in yytname, as it cannot be a non terminal.
This commit is contained in:
@@ -498,13 +498,19 @@ b4_syncline([@oline@], [@ofile@])[
|
||||
message += name_[ilooka_];
|
||||
{
|
||||
int count = 0;
|
||||
for (int x = (n_ < 0 ? -n_ : 0); x < ntokens_ + nnts_; ++x)
|
||||
/* Start YYX at -YYN if negative to avoid negative indexes in
|
||||
YYCHECK. */
|
||||
int xbegin = n_ < 0 ? -n_ : 0;
|
||||
/* Stay within bounds of both yycheck and yytname. */
|
||||
int checklim = last_ - n_;
|
||||
int xend = checklim < ntokens_ ? checklim : ntokens_;
|
||||
for (int x = xbegin; x < xend; ++x)
|
||||
if (check_[x + n_] == x && x != terror_)
|
||||
++count;
|
||||
if (count < 5)
|
||||
{
|
||||
count = 0;
|
||||
for (int x = (n_ < 0 ? -n_ : 0); x < ntokens_ + nnts_; ++x)
|
||||
for (int x = xbegin; x < xend; ++x)
|
||||
if (check_[x + n_] == x && x != terror_)
|
||||
{
|
||||
message += (!count++) ? ", expecting " : " or ";
|
||||
|
||||
Reference in New Issue
Block a user