Port small part of master's 11707b2b so future ports are easier.

* data/lalr1.java (YYParser::yysyntax_error): Untabify.
This commit is contained in:
Joel E. Denny
2009-12-22 17:22:24 -05:00
parent 8200219a2a
commit 70afaf2603
2 changed files with 34 additions and 29 deletions

View File

@@ -1,3 +1,8 @@
2009-12-22 Joel E. Denny <jdenny@clemson.edu>
Port small part of master's 11707b2b so future ports are easier.
* data/lalr1.java (YYParser::yysyntax_error): Untabify.
2008-12-11 Akim Demaille <demaille@gostai.com> 2008-12-11 Akim Demaille <demaille@gostai.com>
Simplify the i18n of the error messages. Simplify the i18n of the error messages.

View File

@@ -686,38 +686,38 @@ m4_popdef([b4_at_dollar])])dnl
int yyn = yypact_[yystate]; int yyn = yypact_[yystate];
if (yypact_ninf_ < yyn && yyn <= yylast_) if (yypact_ninf_ < yyn && yyn <= yylast_)
{ {
StringBuffer res; StringBuffer res;
/* Start YYX at -YYN if negative to avoid negative indexes in /* Start YYX at -YYN if negative to avoid negative indexes in
YYCHECK. In other words, skip the first -YYN actions for this YYCHECK. In other words, skip the first -YYN actions for this
state because they are default actions. */ state because they are default actions. */
int yyxbegin = yyn < 0 ? -yyn : 0; int yyxbegin = yyn < 0 ? -yyn : 0;
/* Stay within bounds of both yycheck and yytname. */ /* Stay within bounds of both yycheck and yytname. */
int yychecklim = yylast_ - yyn + 1; int yychecklim = yylast_ - yyn + 1;
int yyxend = yychecklim < yyntokens_ ? yychecklim : yyntokens_; int yyxend = yychecklim < yyntokens_ ? yychecklim : yyntokens_;
int count = 0; int count = 0;
for (int x = yyxbegin; x < yyxend; ++x) for (int x = yyxbegin; x < yyxend; ++x)
if (yycheck_[x + yyn] == x && x != yyterror_ if (yycheck_[x + yyn] == x && x != yyterror_
&& !yy_table_value_is_error_ (yytable_[x + yyn])) && !yy_table_value_is_error_ (yytable_[x + yyn]))
++count; ++count;
// FIXME: This method of building the message is not compatible // FIXME: This method of building the message is not compatible
// with internationalization. // with internationalization.
res = new StringBuffer ("syntax error, unexpected "); res = new StringBuffer ("syntax error, unexpected ");
res.append (yytnamerr_ (yytname_[tok])); res.append (yytnamerr_ (yytname_[tok]));
if (count < 5) if (count < 5)
{ {
count = 0; count = 0;
for (int x = yyxbegin; x < yyxend; ++x) for (int x = yyxbegin; x < yyxend; ++x)
if (yycheck_[x + yyn] == x && x != yyterror_ if (yycheck_[x + yyn] == x && x != yyterror_
&& !yy_table_value_is_error_ (yytable_[x + yyn])) && !yy_table_value_is_error_ (yytable_[x + yyn]))
{ {
res.append (count++ == 0 ? ", expecting " : " or "); res.append (count++ == 0 ? ", expecting " : " or ");
res.append (yytnamerr_ (yytname_[x])); res.append (yytnamerr_ (yytname_[x]));
} }
} }
return res.toString (); return res.toString ();
} }
} }