symbols: stop dealing with YYEMPTY as b4_symbol(-2, ...)

* data/skeletons/bison.m4 (b4_symbol): Redirect `b4_symbol(empty,
...)` to `b4_symbol(-2, ...)`.
Change all uses of the latter to the former.
This commit is contained in:
Akim Demaille
2020-09-29 06:27:31 +02:00
parent a7daa63cb7
commit cd40ec9526
9 changed files with 77 additions and 75 deletions

View File

@@ -480,16 +480,18 @@ m4_define([b4_symbol_slot],
# b4_symbol(NUM, FIELD) # b4_symbol(NUM, FIELD)
# --------------------- # ---------------------
# Fetch FIELD of symbol #NUM (or "orig NUM"). Fail if undefined. # Fetch FIELD of symbol #NUM (or "orig NUM", or "empty"). Fail if undefined.
# #
# If FIELD = id, prepend the token prefix. # If FIELD = id, prepend the token prefix.
m4_define([b4_symbol], m4_define([b4_symbol],
[m4_case([$2], [m4_if([$1], [empty],
[id], [b4_symbol_token_kind([$1])], [b4_symbol([-2], [$2])],
[kind_base], [b4_symbol_kind_base([$1])], [m4_case([$2],
[kind], [b4_symbol_kind([$1])], [id], [b4_symbol_token_kind([$1])],
[slot], [b4_symbol_slot([$1])], [kind_base], [b4_symbol_kind_base([$1])],
[_b4_symbol($@)])]) [kind], [b4_symbol_kind([$1])],
[slot], [b4_symbol_slot([$1])],
[_b4_symbol($@)])])])
# b4_symbol_if(NUM, FIELD, IF-TRUE, IF-FALSE) # b4_symbol_if(NUM, FIELD, IF-TRUE, IF-FALSE)

View File

@@ -192,7 +192,7 @@ m4_define([b4_declare_symbol_enum],
[[enum symbol_kind_type [[enum symbol_kind_type
{ {
YYNTOKENS = ]b4_tokens_number[, ///< Number of tokens. YYNTOKENS = ]b4_tokens_number[, ///< Number of tokens.
]b4_symbol(-2, kind_base)[ = -2, ]b4_symbol(empty, kind_base)[ = -2,
]b4_symbol_foreach([ b4_symbol_enum])dnl ]b4_symbol_foreach([ b4_symbol_enum])dnl
[ };]]) [ };]])
@@ -506,7 +506,7 @@ m4_define([b4_public_types_define],
bool bool
]b4_parser_class[::basic_symbol<Base>::empty () const YY_NOEXCEPT ]b4_parser_class[::basic_symbol<Base>::empty () const YY_NOEXCEPT
{ {
return this->kind () == ]b4_symbol(-2, kind)[; return this->kind () == ]b4_symbol(empty, kind)[;
} }
template <typename Base> template <typename Base>
@@ -522,7 +522,7 @@ m4_define([b4_public_types_define],
// by_kind. // by_kind.
]b4_inline([$1])b4_parser_class[::by_kind::by_kind () ]b4_inline([$1])b4_parser_class[::by_kind::by_kind ()
: kind_ (]b4_symbol(-2, kind)[) : kind_ (]b4_symbol(empty, kind)[)
{} {}
#if 201103L <= YY_CPLUSPLUS #if 201103L <= YY_CPLUSPLUS
@@ -544,7 +544,7 @@ m4_define([b4_public_types_define],
]b4_inline([$1])[void ]b4_inline([$1])[void
]b4_parser_class[::by_kind::clear () ]b4_parser_class[::by_kind::clear ()
{ {
kind_ = ]b4_symbol(-2, kind)[; kind_ = ]b4_symbol(empty, kind)[;
} }
]b4_inline([$1])[void ]b4_inline([$1])[void

View File

@@ -186,7 +186,7 @@ m4_define([b4_token_enum],
m4_define([b4_token_enums], m4_define([b4_token_enums],
[/* Token kinds. */ [/* Token kinds. */
public enum TokenKind { public enum TokenKind {
]b4_symbol(-2, id)[ = -2, ]b4_symbol(empty, id)[ = -2,
b4_symbol_foreach([b4_token_enum])dnl b4_symbol_foreach([b4_token_enum])dnl
} }
]) ])
@@ -227,7 +227,7 @@ m4_define([b4_declare_symbol_enum],
{ {
enum enum
{ {
]b4_symbol(-2, kind_base)[ = -2, /* No symbol. */ ]b4_symbol(empty, kind_base)[ = -2, /* No symbol. */
]b4_symbol_foreach([b4_symbol_enum])dnl ]b4_symbol_foreach([b4_symbol_enum])dnl
[ } [ }

View File

@@ -527,7 +527,7 @@ struct yyGLRStateSet {
/** During nondeterministic operation, yylookaheadNeeds tracks which /** During nondeterministic operation, yylookaheadNeeds tracks which
* stacks have actually needed the current lookahead. During deterministic * stacks have actually needed the current lookahead. During deterministic
* operation, yylookaheadNeeds[0] is not maintained since it would merely * operation, yylookaheadNeeds[0] is not maintained since it would merely
* duplicate yychar != ]b4_symbol(-2, id)[. */ * duplicate yychar != ]b4_symbol(empty, id)[. */
yybool* yylookaheadNeeds; yybool* yylookaheadNeeds;
YYPTRDIFF_T yysize; YYPTRDIFF_T yysize;
YYPTRDIFF_T yycapacity; YYPTRDIFF_T yycapacity;
@@ -811,7 +811,7 @@ yygetToken (int *yycharp][]b4_pure_if([, yyGLRStack* yystackp])[]b4_user_formals
{ {
yysymbol_kind_t yytoken; yysymbol_kind_t yytoken;
]b4_parse_param_use()dnl ]b4_parse_param_use()dnl
[ if (*yycharp == ]b4_symbol(-2, id)[) [ if (*yycharp == ]b4_symbol(empty, id)[)
{ {
YY_DPRINTF ((stderr, "Reading a token\n"));]b4_glr_cc_if([[ YY_DPRINTF ((stderr, "Reading a token\n"));]b4_glr_cc_if([[
#if YY_EXCEPTIONS #if YY_EXCEPTIONS
@@ -889,7 +889,7 @@ yyuserAction (yyRuleNum yyn, int yyrhslen, yyGLRStackItem* yyvsp,
# undef YYRECOVERING # undef YYRECOVERING
# define YYRECOVERING() (yystackp->yyerrState != 0) # define YYRECOVERING() (yystackp->yyerrState != 0)
# undef yyclearin # undef yyclearin
# define yyclearin (yychar = ]b4_symbol(-2, id)[) # define yyclearin (yychar = ]b4_symbol(empty, id)[)
# undef YYFILL # undef YYFILL
# define YYFILL(N) yyfill (yyvsp, &yylow, (N), yynormal) # define YYFILL(N) yyfill (yyvsp, &yylow, (N), yynormal)
# undef YYBACKUP # undef YYBACKUP
@@ -1121,7 +1121,7 @@ yyaddDeferredAction (yyGLRStack* yystackp, YYPTRDIFF_T yyk, yyGLRState* yystate,
yynewOption->yyloc = yylloc;])[ yynewOption->yyloc = yylloc;])[
} }
else else
yynewOption->yyrawchar = ]b4_symbol(-2, id)[; yynewOption->yyrawchar = ]b4_symbol(empty, id)[;
yynewOption->yynext = yystate->yysemantics.yyfirstVal; yynewOption->yynext = yystate->yysemantics.yyfirstVal;
yystate->yysemantics.yyfirstVal = yynewOption; yystate->yysemantics.yyfirstVal = yynewOption;
@@ -2124,7 +2124,7 @@ yypcontext_expected_tokens (const yyGLRStack* yystackp,
} }
} }
if (yyarg && yycount == 0 && 0 < yyargn) if (yyarg && yycount == 0 && 0 < yyargn)
yyarg[0] = ]b4_symbol(-2, kind)[; yyarg[0] = ]b4_symbol(empty, kind)[;
return yycount; return yycount;
}]])[ }]])[
@@ -2143,7 +2143,7 @@ static yysymbol_kind_t
yypcontext_token (const yyGLRStack *yystackp) yypcontext_token (const yyGLRStack *yystackp)
{ {
YYUSE (yystackp); YYUSE (yystackp);
yysymbol_kind_t yytoken = yychar == ]b4_symbol(-2, id)[ ? ]b4_symbol(-2, kind)[ : YYTRANSLATE (yychar); yysymbol_kind_t yytoken = yychar == ]b4_symbol(empty, id)[ ? ]b4_symbol(empty, kind)[ : YYTRANSLATE (yychar);
return yytoken; return yytoken;
} }
@@ -2162,7 +2162,7 @@ yypcontext_location (const yyGLRStack *yystackp)
yy_syntax_error_arguments (const yyGLRStack* yystackp, yy_syntax_error_arguments (const yyGLRStack* yystackp,
yysymbol_kind_t yyarg[], int yyargn) yysymbol_kind_t yyarg[], int yyargn)
{ {
yysymbol_kind_t yytoken = yychar == ]b4_symbol(-2, id)[ ? ]b4_symbol(-2, kind)[ : YYTRANSLATE (yychar); yysymbol_kind_t yytoken = yychar == ]b4_symbol(empty, id)[ ? ]b4_symbol(empty, kind)[ : YYTRANSLATE (yychar);
/* Actual size of YYARG. */ /* Actual size of YYARG. */
int yycount = 0; int yycount = 0;
/* There are many possibilities here to consider: /* There are many possibilities here to consider:
@@ -2193,7 +2193,7 @@ yy_syntax_error_arguments (const yyGLRStack* yystackp,
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_symbol(-2, kind)[) if (yytoken != ]b4_symbol(empty, kind)[)
{ {
int yyn; int yyn;
if (yyarg) if (yyarg)
@@ -2322,7 +2322,7 @@ yyrecoverSyntaxError (yyGLRStack* yystackp]b4_user_formals[)
int yyj; int yyj;
if (yychar == ]b4_symbol(0, [id])[) if (yychar == ]b4_symbol(0, [id])[)
yyFail (yystackp][]b4_lpure_args[, YY_NULLPTR); yyFail (yystackp][]b4_lpure_args[, YY_NULLPTR);
if (yychar != ]b4_symbol(-2, id)[) if (yychar != ]b4_symbol(empty, id)[)
{]b4_locations_if([[ {]b4_locations_if([[
/* We throw away the lookahead, but the error range /* We throw away the lookahead, but the error range
of the shifted error token must take it into account. */ of the shifted error token must take it into account. */
@@ -2334,7 +2334,7 @@ yyrecoverSyntaxError (yyGLRStack* yystackp]b4_user_formals[)
yytoken = YYTRANSLATE (yychar); yytoken = YYTRANSLATE (yychar);
yydestruct ("Error: discarding", yydestruct ("Error: discarding",
yytoken, &yylval]b4_locuser_args([&yylloc])[); yytoken, &yylval]b4_locuser_args([&yylloc])[);
yychar = ]b4_symbol(-2, id)[; yychar = ]b4_symbol(empty, id)[;
} }
yytoken = ]b4_yygetToken_call[; yytoken = ]b4_yygetToken_call[;
yyj = yypact[yystackp->yytops.yystates[0]->yylrState]; yyj = yypact[yystackp->yytops.yystates[0]->yylrState];
@@ -2431,7 +2431,7 @@ yyparse (]m4_ifset([b4_parse_param], [b4_formals(b4_parse_param)], [void])[)
YY_DPRINTF ((stderr, "Starting parse\n")); YY_DPRINTF ((stderr, "Starting parse\n"));
yychar = ]b4_symbol(-2, id)[; yychar = ]b4_symbol(empty, id)[;
yylval = yyval_default;]b4_locations_if([ yylval = yyval_default;]b4_locations_if([
yylloc = yyloc_default;])[ yylloc = yyloc_default;])[
]m4_ifdef([b4_initial_action], [ ]m4_ifdef([b4_initial_action], [
@@ -2485,7 +2485,7 @@ b4_dollar_popdef])[]dnl
if (yyisShiftAction (yyaction)) if (yyisShiftAction (yyaction))
{ {
YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
yychar = ]b4_symbol(-2, id)[; yychar = ]b4_symbol(empty, id)[;
yyposn += 1; yyposn += 1;
yyglrShift (&yystack, 0, yyaction, yyposn, &yylval]b4_locations_if([, &yylloc])[); yyglrShift (&yystack, 0, yyaction, yyposn, &yylval]b4_locations_if([, &yylloc])[);
if (0 < yystack.yyerrState) if (0 < yystack.yyerrState)
@@ -2512,7 +2512,7 @@ b4_dollar_popdef])[]dnl
YYPTRDIFF_T yys; YYPTRDIFF_T yys;
for (yys = 0; yys < yystack.yytops.yysize; yys += 1) for (yys = 0; yys < yystack.yytops.yysize; yys += 1)
yystackp->yytops.yylookaheadNeeds[yys] = yychar != ]b4_symbol(-2, id)[; yystackp->yytops.yylookaheadNeeds[yys] = yychar != ]b4_symbol(empty, id)[;
/* yyprocessOneStack returns one of three things: /* yyprocessOneStack returns one of three things:
@@ -2550,11 +2550,11 @@ b4_dollar_popdef])[]dnl
/* If any yyglrShift call fails, it will fail after shifting. Thus, /* If any yyglrShift call fails, it will fail after shifting. Thus,
a copy of yylval will already be on stack 0 in the event of a a copy of yylval will already be on stack 0 in the event of a
failure in the following loop. Thus, yychar is set to ]b4_symbol(-2, id)[ failure in the following loop. Thus, yychar is set to ]b4_symbol(empty, id)[
before the loop to make sure the user destructor for yylval isn't before the loop to make sure the user destructor for yylval isn't
called twice. */ called twice. */
yytoken_to_shift = YYTRANSLATE (yychar); yytoken_to_shift = YYTRANSLATE (yychar);
yychar = ]b4_symbol(-2, id)[; yychar = ]b4_symbol(empty, id)[;
yyposn += 1; yyposn += 1;
for (yys = 0; yys < yystack.yytops.yysize; yys += 1) for (yys = 0; yys < yystack.yytops.yysize; yys += 1)
{ {
@@ -2604,7 +2604,7 @@ b4_dollar_popdef])[]dnl
goto yyreturn; goto yyreturn;
yyreturn: yyreturn:
if (yychar != ]b4_symbol(-2, id)[) if (yychar != ]b4_symbol(empty, id)[)
yydestruct ("Cleanup: discarding lookahead", yydestruct ("Cleanup: discarding lookahead",
YYTRANSLATE (yychar), &yylval]b4_locuser_args([&yylloc])[); YYTRANSLATE (yychar), &yylval]b4_locuser_args([&yylloc])[);

View File

@@ -239,8 +239,8 @@ m4_define([b4_glr_cc_setup],
# pragma clang diagnostic ignored "-Wc++11-long-long" # pragma clang diagnostic ignored "-Wc++11-long-long"
#endif #endif
#undef ]b4_symbol(-2, [id])[ #undef ]b4_symbol(empty, [id])[
#define ]b4_symbol(-2, [id])[ ]b4_namespace_ref[::]b4_parser_class[::token::]b4_symbol(-2, [id])[ #define ]b4_symbol(empty, [id])[ ]b4_namespace_ref[::]b4_parser_class[::token::]b4_symbol(empty, [id])[
#undef ]b4_symbol(0, [id])[ #undef ]b4_symbol(0, [id])[
#define ]b4_symbol(0, [id])[ ]b4_namespace_ref[::]b4_parser_class[::token::]b4_symbol(0, [id])[ #define ]b4_symbol(0, [id])[ ]b4_namespace_ref[::]b4_parser_class[::token::]b4_symbol(0, [id])[
#undef ]b4_symbol(1, [id])[ #undef ]b4_symbol(1, [id])[
@@ -270,7 +270,7 @@ m4_define([b4_undef_symbol_kind],
# ----------------- # -----------------
# Remove redirections for glr.c. # Remove redirections for glr.c.
m4_define([b4_glr_cc_cleanup], m4_define([b4_glr_cc_cleanup],
[[#undef ]b4_symbol(-2, [id])[ [[#undef ]b4_symbol(empty, [id])[
#undef ]b4_symbol(0, [id])[ #undef ]b4_symbol(0, [id])[
#undef ]b4_symbol(1, [id])[ #undef ]b4_symbol(1, [id])[

View File

@@ -90,7 +90,7 @@ typedef ]b4_namespace_ref[::]b4_parser_class[::symbol_kind_type yysymbol_kind_t;
# ----------------- # -----------------
# Remove redirections for glr.c. # Remove redirections for glr.c.
m4_define([b4_glr_cc_cleanup], m4_define([b4_glr_cc_cleanup],
[[#undef ]b4_symbol(-2, [id])[ [[#undef ]b4_symbol(empty, [id])[
#undef ]b4_symbol(0, [id])[ #undef ]b4_symbol(0, [id])[
#undef ]b4_symbol(1, [id])[ #undef ]b4_symbol(1, [id])[
#undef ]b4_symbol_prefix[YYEMPTY #undef ]b4_symbol_prefix[YYEMPTY
@@ -571,7 +571,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<yysymbol_kind_t>(yytranslate[YYX]) \ ? static_cast<yysymbol_kind_t>(yytranslate[YYX]) \
: ]b4_namespace_ref::b4_parser_class::b4_symbol(-2, kind)[) : ]b4_namespace_ref::b4_parser_class::b4_symbol(empty, 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. */
@@ -1026,7 +1026,7 @@ class glr_state_set {
/** During nondeterministic operation, yylookaheadNeeds tracks which /** During nondeterministic operation, yylookaheadNeeds tracks which
* stacks have actually needed the current lookahead. During deterministic * stacks have actually needed the current lookahead. During deterministic
* operation, yylookaheadNeeds[0] is not maintained since it would merely * operation, yylookaheadNeeds[0] is not maintained since it would merely
* duplicate yychar != ]b4_symbol(-2, id)[. */ * duplicate yychar != ]b4_symbol(empty, id)[. */
std::vector<bool> yylookaheadNeeds; std::vector<bool> yylookaheadNeeds;
/** The last stack we invalidated. */ /** The last stack we invalidated. */
@@ -1790,7 +1790,7 @@ public:
~glr_stack () ~glr_stack ()
{ {
if (yychar != ]b4_namespace_ref::b4_parser_class::token::b4_symbol(-2, id)[) if (yychar != ]b4_namespace_ref::b4_parser_class::token::b4_symbol(empty, id)[)
yyparser.yy_destroy_ ("Cleanup: discarding lookahead", yyparser.yy_destroy_ ("Cleanup: discarding lookahead",
YYTRANSLATE (yychar), &yylval]b4_locations_if([, &yylloc])[); YYTRANSLATE (yychar), &yylval]b4_locations_if([, &yylloc])[);
popall(); popall();
@@ -1841,7 +1841,7 @@ public:
glr_state* yyrhs, rule_num yyrule) glr_state* yyrhs, rule_num yyrule)
{ {
semantic_option& yynewOption = semantic_option& yynewOption =
yystateStack.yynewSemanticOption(semantic_option(yyrule, ]b4_namespace_ref::b4_parser_class::token::b4_symbol(-2, id)[)); yystateStack.yynewSemanticOption(semantic_option(yyrule, ]b4_namespace_ref::b4_parser_class::token::b4_symbol(empty, id)[));
yynewOption.setState(yyrhs); yynewOption.setState(yyrhs);
yynewOption.setNext(yystate->firstVal()); yynewOption.setNext(yystate->firstVal());
if (yystateStack.yytops.lookaheadNeeds(yyk)) if (yystateStack.yytops.lookaheadNeeds(yyk))
@@ -1870,13 +1870,13 @@ public:
[[ yyparser.error (]b4_locations_if([yylloc, ])[YY_("syntax error"));]], [[ yyparser.error (]b4_locations_if([yylloc, ])[YY_("syntax error"));]],
[[ { [[ {
yysymbol_kind_t yytoken yysymbol_kind_t yytoken
= yychar == ]b4_namespace_ref::b4_parser_class::token::b4_symbol(-2, id)[ = yychar == ]b4_namespace_ref::b4_parser_class::token::b4_symbol(empty, id)[
? ]b4_namespace_ref::b4_parser_class::b4_symbol(-2, kind)[ ? ]b4_namespace_ref::b4_parser_class::b4_symbol(empty, kind)[
: YYTRANSLATE (yychar); : YYTRANSLATE (yychar);
enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
/* Arguments of yyformat. */ /* Arguments of yyformat. */
yysymbol_kind_t yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM] yysymbol_kind_t yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]
= { ]b4_namespace_ref::b4_parser_class::b4_symbol(-2, kind)[ }; = { ]b4_namespace_ref::b4_parser_class::b4_symbol(empty, kind)[ };
/* Number of reported tokens (one for the "unexpected", one per /* Number of reported tokens (one for the "unexpected", one per
"expected"). */ "expected"). */
int yycount = 0; int yycount = 0;
@@ -1904,7 +1904,7 @@ public:
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::b4_symbol(-2, kind)[) if (yytoken != ]b4_namespace_ref::b4_parser_class::b4_symbol(empty, kind)[)
{ {
int yyn = yypact[firstTopState()->yylrState]; int yyn = yypact[firstTopState()->yylrState];
yyarg[yycount++] = yytoken; yyarg[yycount++] = yytoken;
@@ -1983,7 +1983,7 @@ public:
int yyj; int yyj;
if (yychar == ]b4_namespace_ref::b4_parser_class::token::b4_symbol(0, id)[) if (yychar == ]b4_namespace_ref::b4_parser_class::token::b4_symbol(0, id)[)
yyFail (]b4_locations_if([yylocp, ])[YY_NULLPTR); yyFail (]b4_locations_if([yylocp, ])[YY_NULLPTR);
if (yychar != ]b4_namespace_ref::b4_parser_class::token::b4_symbol(-2, id)[) if (yychar != ]b4_namespace_ref::b4_parser_class::token::b4_symbol(empty, id)[)
{]b4_locations_if([[ {]b4_locations_if([[
/* We throw away the lookahead, but the error range /* We throw away the lookahead, but the error range
of the shifted error token must take it into account. */ of the shifted error token must take it into account. */
@@ -1994,7 +1994,7 @@ public:
yytoken = YYTRANSLATE (yychar); yytoken = YYTRANSLATE (yychar);
yyparser.yy_destroy_ ("Error: discarding", yyparser.yy_destroy_ ("Error: discarding",
yytoken, &yylval]b4_locations_if([, &yylloc])[); yytoken, &yylval]b4_locations_if([, &yylloc])[);
yychar = ]b4_namespace_ref::b4_parser_class::token::b4_symbol(-2, id)[; yychar = ]b4_namespace_ref::b4_parser_class::token::b4_symbol(empty, id)[;
} }
yytoken = ]b4_yygetToken_call[; yytoken = ]b4_yygetToken_call[;
yyj = yypact[firstTopState()->yylrState]; yyj = yypact[firstTopState()->yylrState];
@@ -2159,7 +2159,7 @@ public:
# undef YYRECOVERING # undef YYRECOVERING
# define YYRECOVERING() (yyerrState != 0) # define YYRECOVERING() (yyerrState != 0)
# undef yyclearin # undef yyclearin
# define yyclearin (yychar = ]b4_namespace_ref::b4_parser_class::token::b4_symbol(-2, id)[) # define yyclearin (yychar = ]b4_namespace_ref::b4_parser_class::token::b4_symbol(empty, id)[)
# undef YYBACKUP # undef YYBACKUP
# define YYBACKUP(Token, Value) \ # define YYBACKUP(Token, Value) \
return yyparser.error (]b4_locations_if([*yylocp, ])[YY_("syntax error: cannot back up")), \ return yyparser.error (]b4_locations_if([*yylocp, ])[YY_("syntax error: cannot back up")), \
@@ -2621,7 +2621,7 @@ yygetToken (int *yycharp, ]b4_namespace_ref[::]b4_parser_class[& yyparser][]b4_p
{ {
yysymbol_kind_t yytoken; yysymbol_kind_t yytoken;
]b4_parse_param_use()dnl ]b4_parse_param_use()dnl
[ if (*yycharp == ]b4_namespace_ref::b4_parser_class::token::b4_symbol(-2, id)[) [ if (*yycharp == ]b4_namespace_ref::b4_parser_class::token::b4_symbol(empty, id)[)
{ {
YY_DEBUG_STREAM << "Reading a token\n"; YY_DEBUG_STREAM << "Reading a token\n";
#if YY_EXCEPTIONS #if YY_EXCEPTIONS
@@ -2788,7 +2788,7 @@ yyparse (]b4_namespace_ref[::]b4_parser_class[& yyparser]b4_user_formals[)
YY_DEBUG_STREAM << "Starting parse\n"; YY_DEBUG_STREAM << "Starting parse\n";
yychar = ]b4_namespace_ref::b4_parser_class::token::b4_symbol(-2, id)[; yychar = ]b4_namespace_ref::b4_parser_class::token::b4_symbol(empty, id)[;
yylval = yyval_default;]b4_locations_if([ yylval = yyval_default;]b4_locations_if([
yylloc = yyloc_default;])[ yylloc = yyloc_default;])[
]m4_ifdef([b4_initial_action], [ ]m4_ifdef([b4_initial_action], [
@@ -2839,7 +2839,7 @@ b4_dollar_popdef])[]dnl
if (yyisShiftAction (yyaction)) if (yyisShiftAction (yyaction))
{ {
YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
yychar = ]b4_namespace_ref::b4_parser_class::token::b4_symbol(-2, id)[; yychar = ]b4_namespace_ref::b4_parser_class::token::b4_symbol(empty, id)[;
yyposn += 1; yyposn += 1;
yystack.yyglrShift (create_state_set_index(0), yyaction, yyposn, &yylval]b4_locations_if([, &yylloc])[); yystack.yyglrShift (create_state_set_index(0), yyaction, yyposn, &yylval]b4_locations_if([, &yylloc])[);
if (0 < yystack.yyerrState) if (0 < yystack.yyerrState)
@@ -2864,7 +2864,7 @@ b4_dollar_popdef])[]dnl
yysymbol_kind_t yytoken_to_shift; yysymbol_kind_t yytoken_to_shift;
for (state_set_index yys = create_state_set_index(0); yys.uget() < yystack.yystateStack.numTops(); ++yys) for (state_set_index yys = create_state_set_index(0); yys.uget() < yystack.yystateStack.numTops(); ++yys)
yystackp->yystateStack.yytops.setLookaheadNeeds(yys, yychar != ]b4_namespace_ref::b4_parser_class::token::b4_symbol(-2, id)[); yystackp->yystateStack.yytops.setLookaheadNeeds(yys, yychar != ]b4_namespace_ref::b4_parser_class::token::b4_symbol(empty, id)[);
/* yyprocessOneStack returns one of three things: /* yyprocessOneStack returns one of three things:
@@ -2902,11 +2902,11 @@ b4_dollar_popdef])[]dnl
/* If any yyglrShift call fails, it will fail after shifting. Thus, /* If any yyglrShift call fails, it will fail after shifting. Thus,
a copy of yylval will already be on stack 0 in the event of a a copy of yylval will already be on stack 0 in the event of a
failure in the following loop. Thus, yychar is set to ]b4_symbol(-2, id)[ failure in the following loop. Thus, yychar is set to ]b4_symbol(empty, id)[
before the loop to make sure the user destructor for yylval isn't before the loop to make sure the user destructor for yylval isn't
called twice. */ called twice. */
yytoken_to_shift = YYTRANSLATE (yychar); yytoken_to_shift = YYTRANSLATE (yychar);
yychar = ]b4_namespace_ref::b4_parser_class::token::b4_symbol(-2, id)[; yychar = ]b4_namespace_ref::b4_parser_class::token::b4_symbol(empty, id)[;
yyposn += 1; yyposn += 1;
for (state_set_index yys = create_state_set_index(0); yys.uget() < yystack.yystateStack.numTops(); ++yys) for (state_set_index yys = create_state_set_index(0); yys.uget() < yystack.yystateStack.numTops(); ++yys)
{ {

View File

@@ -408,7 +408,7 @@ m4_define([b4_shared_declarations],
void move (by_state& that); void move (by_state& that);
/// The symbol kind (corresponding to \a state). /// The symbol kind (corresponding to \a state).
/// \a ]b4_symbol(-2, kind)[ when empty. /// \a ]b4_symbol(empty, kind)[ when empty.
symbol_kind_type kind () const YY_NOEXCEPT; symbol_kind_type kind () const YY_NOEXCEPT;
/// The state number used to denote an empty symbol. /// The state number used to denote an empty symbol.
@@ -665,7 +665,7 @@ m4_if(b4_prefix, [yy], [],
]b4_parser_class[::by_state::kind () const YY_NOEXCEPT ]b4_parser_class[::by_state::kind () const YY_NOEXCEPT
{ {
if (state == empty_state) if (state == empty_state)
return ]b4_symbol(-2, kind)[; return ]b4_symbol(empty, kind)[;
else else
return YY_CAST (symbol_kind_type, yystos_[+state]); return YY_CAST (symbol_kind_type, yystos_[+state]);
} }
@@ -690,7 +690,7 @@ m4_if(b4_prefix, [yy], [],
b4_symbol_variant([that.kind ()], b4_symbol_variant([that.kind ()],
[value], [move], [YY_MOVE (that.value)])])[ [value], [move], [YY_MOVE (that.value)])])[
// that is emptied. // that is emptied.
that.kind_ = ]b4_symbol(-2, kind)[; that.kind_ = ]b4_symbol(empty, kind)[;
} }
#if YY_CPLUSPLUS < 201103L #if YY_CPLUSPLUS < 201103L
@@ -1333,7 +1333,7 @@ b4_dollar_popdef])[]dnl
} }
]])[ ]])[
if (yyarg && yycount == 0 && 0 < yyargn) if (yyarg && yycount == 0 && 0 < yyargn)
yyarg[0] = ]b4_symbol(-2, kind)[; yyarg[0] = ]b4_symbol(empty, kind)[;
return yycount; return yycount;
} }

View File

@@ -394,9 +394,9 @@ b4_locations_if([, ref ]b4_location_type[ yylocationp])[)
public bool parse () public bool parse ()
{ {
// Lookahead token kind. // Lookahead token kind.
int yychar = TokenKind.]b4_symbol(-2, id)[; int yychar = TokenKind.]b4_symbol(empty, id)[;
// Lookahead symbol kind. // Lookahead symbol kind.
SymbolKind yytoken = ]b4_symbol(-2, kind)[; SymbolKind yytoken = ]b4_symbol(empty, kind)[;
/* State. */ /* State. */
int yyn = 0; int yyn = 0;
@@ -459,7 +459,7 @@ m4_popdef([b4_at_dollar])])dnl
} }
/* Read a lookahead token. */ /* Read a lookahead token. */
if (yychar == TokenKind.]b4_symbol(-2, id)[) if (yychar == TokenKind.]b4_symbol(empty, id)[)
{]b4_parse_trace_if([[ {]b4_parse_trace_if([[
yycdebugln ("Reading a token");]])[ yycdebugln ("Reading a token");]])[
yychar = yylex ();]b4_locations_if([[ yychar = yylex ();]b4_locations_if([[
@@ -511,7 +511,7 @@ m4_popdef([b4_at_dollar])])dnl
yy_symbol_print ("Shifting", yytoken, yylval]b4_locations_if([, yylloc])[);]])[ yy_symbol_print ("Shifting", yytoken, yylval]b4_locations_if([, yylloc])[);]])[
/* Discard the token being shifted. */ /* Discard the token being shifted. */
yychar = TokenKind.]b4_symbol(-2, id)[; yychar = TokenKind.]b4_symbol(empty, id)[;
/* Count tokens shifted since error; after three, turn off error /* Count tokens shifted since error; after three, turn off error
* status. */ * status. */
@@ -553,8 +553,8 @@ m4_popdef([b4_at_dollar])])dnl
if (yyerrstatus_ == 0) if (yyerrstatus_ == 0)
{ {
++yynerrs_; ++yynerrs_;
if (yychar == TokenKind.]b4_symbol(-2, id)[) if (yychar == TokenKind.]b4_symbol(empty, id)[)
yytoken = ]b4_symbol(-2, kind)[; yytoken = ]b4_symbol(empty, kind)[;
yyerror (]b4_locations_if([yylloc, ])[yysyntax_error (yystate, yytoken)); yyerror (]b4_locations_if([yylloc, ])[yysyntax_error (yystate, yytoken));
} }
]b4_locations_if([ ]b4_locations_if([
@@ -571,7 +571,7 @@ m4_popdef([b4_at_dollar])])dnl
return false; return false;
} }
else else
yychar = TokenKind.]b4_symbol(-2, id)[; yychar = TokenKind.]b4_symbol(empty, id)[;
} }
/* Else will try to reuse lookahead token after shifting the error /* Else will try to reuse lookahead token after shifting the error
@@ -692,7 +692,7 @@ m4_popdef([b4_at_dollar])])dnl
will still contain any token that will not be accepted due will still contain any token that will not be accepted due
to an error action in a later state. to an error action in a later state.
*/ */
if (tok != ]b4_symbol(-2, kind)[) if (tok != ]b4_symbol(empty, kind)[)
{ {
// FIXME: This method of building the message is not compatible // FIXME: This method of building the message is not compatible
// with internationalization. // with internationalization.

View File

@@ -727,7 +727,7 @@ static const ]b4_int_type_for([b4_toknum])[ yytoknum[] =
enum { YYENOMEM = -2 }; enum { YYENOMEM = -2 };
#define yyerrok (yyerrstatus = 0) #define yyerrok (yyerrstatus = 0)
#define yyclearin (yychar = ]b4_symbol(-2, id)[) #define yyclearin (yychar = ]b4_symbol(empty, id)[)
#define YYACCEPT goto yyacceptlab #define YYACCEPT goto yyacceptlab
#define YYABORT goto yyabortlab #define YYABORT goto yyabortlab
@@ -738,7 +738,7 @@ enum { YYENOMEM = -2 };
#define YYBACKUP(Token, Value) \ #define YYBACKUP(Token, Value) \
do \ do \
if (yychar == ]b4_symbol(-2, id)[) \ if (yychar == ]b4_symbol(empty, id)[) \
{ \ { \
yychar = (Token); \ yychar = (Token); \
yylval = (Value); \ yylval = (Value); \
@@ -1206,7 +1206,7 @@ yypcontext_expected_tokens (const yypcontext_t *yyctx,
} }
}]])[ }]])[
if (yyarg && yycount == 0 && 0 < yyargn) if (yyarg && yycount == 0 && 0 < yyargn)
yyarg[0] = ]b4_symbol(-2, kind)[; yyarg[0] = ]b4_symbol(empty, kind)[;
return yycount; return yycount;
} }
@@ -1369,7 +1369,7 @@ yy_syntax_error_arguments (const yypcontext_t *yyctx,
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 (yyctx->yytoken != ]b4_symbol(-2, kind)[) if (yyctx->yytoken != ]b4_symbol(empty, kind)[)
{ {
int yyn;]b4_lac_if([[ int yyn;]b4_lac_if([[
YYDPRINTF ((stderr, "Constructing syntax error message\n"));]])[ YYDPRINTF ((stderr, "Constructing syntax error message\n"));]])[
@@ -1635,7 +1635,7 @@ yyparse (]m4_ifset([b4_parse_param], [b4_formals(b4_parse_param)], [void])[)]])]
/* The return value of yyparse. */ /* The return value of yyparse. */
int yyresult; int yyresult;
/* Lookahead symbol kind. */ /* Lookahead symbol kind. */
yysymbol_kind_t yytoken = ]b4_symbol(-2, kind)[; yysymbol_kind_t yytoken = ]b4_symbol(empty, kind)[;
/* The variables used to return semantic value and location from the /* The variables used to return semantic value and location from the
action routines. */ action routines. */
YYSTYPE yyval;]b4_locations_if([[ YYSTYPE yyval;]b4_locations_if([[
@@ -1671,7 +1671,7 @@ yyparse (]m4_ifset([b4_parse_param], [b4_formals(b4_parse_param)], [void])[)]])]
YYDPRINTF ((stderr, "Starting parse\n")); YYDPRINTF ((stderr, "Starting parse\n"));
]m4_ifdef([b4_start_symbols], [], ]m4_ifdef([b4_start_symbols], [],
[[ yychar = ]b4_symbol(-2, id)[; /* Cause a token to be read. */ [[ yychar = ]b4_symbol(empty, id)[; /* Cause a token to be read. */
]])[ ]])[
]m4_ifdef([b4_initial_action], [ ]m4_ifdef([b4_initial_action], [
b4_dollar_pushdef([m4_define([b4_dollar_dollar_used])yylval], [], [], b4_dollar_pushdef([m4_define([b4_dollar_dollar_used])yylval], [], [],
@@ -1795,7 +1795,7 @@ yybackup:
/* Not known => get a lookahead token if don't already have one. */ /* Not known => get a lookahead token if don't already have one. */
/* YYCHAR is either empty, or end-of-input, or a valid lookahead. */ /* YYCHAR is either empty, or end-of-input, or a valid lookahead. */
if (yychar == ]b4_symbol(-2, id)[) if (yychar == ]b4_symbol(empty, id)[)
{]b4_push_if([[ {]b4_push_if([[
if (!yyps->yynew) if (!yyps->yynew)
{]b4_use_push_for_pull_if([], [[ {]b4_use_push_for_pull_if([], [[
@@ -1876,7 +1876,7 @@ yyread_pushed_token:]])[
*++yylsp = yylloc;])[ *++yylsp = yylloc;])[
/* Discard the shifted token. */ /* Discard the shifted token. */
yychar = ]b4_symbol(-2, id)[;]b4_lac_if([[ yychar = ]b4_symbol(empty, id)[;]b4_lac_if([[
YY_LAC_DISCARD ("shift");]])[ YY_LAC_DISCARD ("shift");]])[
goto yynewstate; goto yynewstate;
@@ -1967,7 +1967,7 @@ yyreduce:
yyerrlab: yyerrlab:
/* Make sure we have latest lookahead translation. See comments at /* Make sure we have latest lookahead translation. See comments at
user semantic actions for why this is necessary. */ user semantic actions for why this is necessary. */
yytoken = yychar == ]b4_symbol(-2, id)[ ? ]b4_symbol(-2, kind)[ : YYTRANSLATE (yychar); yytoken = yychar == ]b4_symbol(empty, id)[ ? ]b4_symbol(empty, kind)[ : YYTRANSLATE (yychar);
/* If not already recovering from an error, report this error. */ /* If not already recovering from an error, report this error. */
if (!yyerrstatus) if (!yyerrstatus)
{ {
@@ -1977,7 +1977,7 @@ yyerrlab:
[[ { [[ {
yypcontext_t yyctx yypcontext_t yyctx
= {]b4_push_if([[yyps]], [[yyssp]b4_lac_if([[, yyesa, &yyes, &yyes_capacity]])])[, yytoken]b4_locations_if([[, &yylloc]])[};]b4_lac_if([[ = {]b4_push_if([[yyps]], [[yyssp]b4_lac_if([[, yyesa, &yyes, &yyes_capacity]])])[, yytoken]b4_locations_if([[, &yylloc]])[};]b4_lac_if([[
if (yychar != ]b4_symbol(-2, id)[) if (yychar != ]b4_symbol(empty, id)[)
YY_LAC_ESTABLISH;]])[ YY_LAC_ESTABLISH;]])[
if (yyreport_syntax_error (&yyctx]m4_ifset([b4_parse_param], if (yyreport_syntax_error (&yyctx]m4_ifset([b4_parse_param],
[[, ]b4_args(b4_parse_param)])[) == 2) [[, ]b4_args(b4_parse_param)])[) == 2)
@@ -1990,7 +1990,7 @@ yyerrlab:
= {]b4_push_if([[yyps]], [[yyssp]b4_lac_if([[, yyesa, &yyes, &yyes_capacity]])])[, yytoken]b4_locations_if([[, &yylloc]])[}; = {]b4_push_if([[yyps]], [[yyssp]b4_lac_if([[, yyesa, &yyes, &yyes_capacity]])])[, yytoken]b4_locations_if([[, &yylloc]])[};
char const *yymsgp = YY_("syntax error"); char const *yymsgp = YY_("syntax error");
int yysyntax_error_status;]b4_lac_if([[ int yysyntax_error_status;]b4_lac_if([[
if (yychar != ]b4_symbol(-2, id)[) if (yychar != ]b4_symbol(empty, id)[)
YY_LAC_ESTABLISH;]])[ YY_LAC_ESTABLISH;]])[
yysyntax_error_status = yysyntax_error (&yymsg_alloc, &yymsg, &yyctx); yysyntax_error_status = yysyntax_error (&yymsg_alloc, &yymsg, &yyctx);
if (yysyntax_error_status == 0) if (yysyntax_error_status == 0)
@@ -2036,7 +2036,7 @@ yyerrlab:
{ {
yydestruct ("Error: discarding", yydestruct ("Error: discarding",
yytoken, &yylval]b4_locations_if([, &yylloc])[]b4_user_args[); yytoken, &yylval]b4_locations_if([, &yylloc])[]b4_user_args[);
yychar = ]b4_symbol(-2, id)[; yychar = ]b4_symbol(empty, id)[;
} }
} }
@@ -2147,7 +2147,7 @@ yyexhaustedlab:
| yyreturn -- parsing is finished, clean up and return. | | yyreturn -- parsing is finished, clean up and return. |
`-------------------------------------------------------*/ `-------------------------------------------------------*/
yyreturn: yyreturn:
if (yychar != ]b4_symbol(-2, id)[) if (yychar != ]b4_symbol(empty, id)[)
{ {
/* Make sure we have latest lookahead translation. See comments at /* Make sure we have latest lookahead translation. See comments at
user semantic actions for why this is necessary. */ user semantic actions for why this is necessary. */