glr2.cc: simplify symbol kinds

We emit code like

    if (yytoken != yy::parser::symbol_kind::symbol_kind::S_YYEMPTY)

* data/skeletons/glr2.cc: Use b4_symbol correctly.
This commit is contained in:
Akim Demaille
2020-09-14 19:20:56 +02:00
parent 11995fec50
commit 243fa94ce2

View File

@@ -606,7 +606,7 @@ static YYLTYPE yyloc_default][]b4_yyloc_default;])[
[[#define YYTRANSLATE(YYX) \ [[#define YYTRANSLATE(YYX) \
(0 <= (YYX) && (YYX) <= ]b4_code_max[ \ (0 <= (YYX) && (YYX) <= ]b4_code_max[ \
? static_cast<]b4_namespace_ref::b4_parser_class[::symbol_kind_type>(yytranslate[YYX]) \ ? static_cast<]b4_namespace_ref::b4_parser_class[::symbol_kind_type>(yytranslate[YYX]) \
: ]b4_namespace_ref::b4_parser_class::symbol_kind::b4_symbol(-2, kind)[) : ]b4_namespace_ref::b4_parser_class::b4_symbol(-2, kind)[)
/* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM /* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM
as returned by yylex. */ as returned by yylex. */
@@ -1907,7 +1907,7 @@ class glr_stack {
[[ { [[ {
]b4_namespace_ref::b4_parser_class[::symbol_kind_type yytoken ]b4_namespace_ref::b4_parser_class[::symbol_kind_type yytoken
= yychar == ]b4_namespace_ref::b4_parser_class::token::b4_symbol(-2, id)[ = yychar == ]b4_namespace_ref::b4_parser_class::token::b4_symbol(-2, id)[
? ]b4_namespace_ref::b4_parser_class::symbol_kind::b4_symbol(-2, kind)[ ? ]b4_namespace_ref::b4_parser_class::b4_symbol(-2, kind)[
: YYTRANSLATE (yychar); : YYTRANSLATE (yychar);
enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
/* Arguments of yyformat. */ /* Arguments of yyformat. */
@@ -1939,7 +1939,7 @@ class glr_stack {
one exception: it will still contain any token that will not be one exception: it will still contain any token that will not be
accepted due to an error action in a later state. accepted due to an error action in a later state.
*/ */
if (yytoken != ]b4_namespace_ref::b4_parser_class::symbol_kind::b4_symbol(-2, kind)[) if (yytoken != ]b4_namespace_ref::b4_parser_class::b4_symbol(-2, kind)[)
{ {
int yyn = yypact[firstTopState()->yylrState]; int yyn = yypact[firstTopState()->yylrState];
yyarg[yycount++] = yytoken; yyarg[yycount++] = yytoken;
@@ -1954,7 +1954,7 @@ class glr_stack {
int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
int yyx; int yyx;
for (yyx = yyxbegin; yyx < yyxend; ++yyx) for (yyx = yyxbegin; yyx < yyxend; ++yyx)
if (yycheck[yyx + yyn] == yyx && yyx != ]b4_namespace_ref::b4_parser_class::symbol_kind::b4_symbol(1, kind)[ if (yycheck[yyx + yyn] == yyx && yyx != ]b4_namespace_ref::b4_parser_class::b4_symbol(1, kind)[
&& !yytable_value_is_error (yytable[yyx + yyn])) && !yytable_value_is_error (yytable[yyx + yyn]))
{ {
if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
@@ -2677,7 +2677,7 @@ yygetToken (int *yycharp, ]b4_namespace_ref[::]b4_parser_class[& yyparser][]b4_p
if (*yycharp <= ]b4_namespace_ref::b4_parser_class::token::b4_symbol(0, id)[) if (*yycharp <= ]b4_namespace_ref::b4_parser_class::token::b4_symbol(0, id)[)
{ {
*yycharp = ]b4_namespace_ref::b4_parser_class::token::b4_symbol(0, id)[; *yycharp = ]b4_namespace_ref::b4_parser_class::token::b4_symbol(0, id)[;
yytoken = ]b4_namespace_ref::b4_parser_class::symbol_kind::b4_symbol(0, kind)[; yytoken = ]b4_namespace_ref::b4_parser_class::b4_symbol(0, kind)[;
YY_DEBUG_STREAM << "Now at end of input.\n"; YY_DEBUG_STREAM << "Now at end of input.\n";
} }
else else
@@ -2724,7 +2724,7 @@ static inline int
yygetLRActions (state_num yystate, ]b4_namespace_ref::b4_parser_class[::symbol_kind_type yytoken, const short** yyconflicts) yygetLRActions (state_num yystate, ]b4_namespace_ref::b4_parser_class[::symbol_kind_type yytoken, const short** yyconflicts)
{ {
int yyindex = yypact[yystate] + yytoken; int yyindex = yypact[yystate] + yytoken;
if (yytoken == ]b4_namespace_ref::b4_parser_class[::symbol_kind::]b4_symbol(1, kind)[) if (yytoken == ]b4_namespace_ref::b4_parser_class[::]b4_symbol(1, kind)[)
{ {
// This is the error token. // This is the error token.
*yyconflicts = yyconfl; *yyconflicts = yyconfl;