mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-09 12:23:04 +00:00
style: avoid explicit symbol numbers
This should have been part of commit "symbols: stop dealing with YYEMPTY
as b4_symbol(-2, ...)" (cd40ec9526).
Give names to all the special symbols: "eof", "error" and "undef".
* data/skeletons/bison.m4 (b4_symbol): Let `b4_symbol(eof, ...)` mean
`b4_symbol(0, ...)`, `b4_symbol(error, ...)` mean `b4_symbol(1, ...)`,
and , `b4_symbol(undef, ...)` mean `b4_symbol(2, ...)`..
* data/skeletons/c.m4, data/skeletons/glr.c, data/skeletons/glr.cc,
* data/skeletons/glr2.cc, data/skeletons/lalr1.cc,
* data/skeletons/lalr1.d, data/skeletons/lalr1.java,
* data/skeletons/yacc.c:
Prefer symbols to numbers.
This commit is contained in:
@@ -918,13 +918,13 @@ b4_dollar_popdef])[]dnl
|
||||
}
|
||||
YY_SYMBOL_PRINT ("Next token is", yyla);
|
||||
|
||||
if (yyla.kind () == ]b4_symbol(1, kind)[)
|
||||
if (yyla.kind () == ]b4_symbol(error, kind)[)
|
||||
{
|
||||
// The scanner already issued an error message, process directly
|
||||
// to error recovery. But do not keep the error token as
|
||||
// lookahead, it is too special and may lead us to an endless
|
||||
// loop in error recovery. */
|
||||
yyla.kind_ = ]b4_symbol(2, kind)[;
|
||||
yyla.kind_ = ]b4_symbol(undef, kind)[;
|
||||
goto yyerrlab1;
|
||||
}
|
||||
|
||||
@@ -1061,7 +1061,7 @@ b4_dollar_popdef])[]dnl
|
||||
error, discard it. */
|
||||
|
||||
// Return failure if at end of input.
|
||||
if (yyla.kind () == ]b4_symbol(0, kind)[)
|
||||
if (yyla.kind () == ]b4_symbol(eof, kind)[)
|
||||
YYABORT;
|
||||
else if (!yyla.empty ())
|
||||
{
|
||||
@@ -1102,9 +1102,9 @@ b4_dollar_popdef])[]dnl
|
||||
yyn = yypact_[+yystack_[0].state];
|
||||
if (!yy_pact_value_is_default_ (yyn))
|
||||
{
|
||||
yyn += ]b4_symbol(1, kind)[;
|
||||
yyn += ]b4_symbol(error, kind)[;
|
||||
if (0 <= yyn && yyn <= yylast_
|
||||
&& yycheck_[yyn] == ]b4_symbol(1, kind)[)
|
||||
&& yycheck_[yyn] == ]b4_symbol(error, kind)[)
|
||||
{
|
||||
yyn = yytable_[yyn];
|
||||
if (0 < yyn)
|
||||
@@ -1296,8 +1296,8 @@ b4_dollar_popdef])[]dnl
|
||||
for (int yyx = 0; yyx < YYNTOKENS; ++yyx)
|
||||
{
|
||||
symbol_kind_type yysym = YY_CAST (symbol_kind_type, yyx);
|
||||
if (yysym != ]b4_symbol(1, kind)[
|
||||
&& yysym != ]b4_symbol(2, kind)[
|
||||
if (yysym != ]b4_symbol(error, kind)[
|
||||
&& yysym != ]b4_symbol(undef, kind)[
|
||||
&& yyparser_.yy_lac_check_ (yysym))
|
||||
{
|
||||
if (!yyarg)
|
||||
@@ -1319,7 +1319,7 @@ b4_dollar_popdef])[]dnl
|
||||
int yychecklim = yylast_ - yyn + 1;
|
||||
int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
|
||||
for (int yyx = yyxbegin; yyx < yyxend; ++yyx)
|
||||
if (yycheck_[yyx + yyn] == yyx && yyx != ]b4_symbol(1, kind)[
|
||||
if (yycheck_[yyx + yyn] == yyx && yyx != ]b4_symbol(error, kind)[
|
||||
&& !yy_table_value_is_error_ (yytable_[yyx + yyn]))
|
||||
{
|
||||
if (!yyarg)
|
||||
|
||||
Reference in New Issue
Block a user