bison-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH for Dlang support] d: support api.symbol.prefix and api.token


From: Akim Demaille
Subject: Re: [PATCH for Dlang support] d: support api.symbol.prefix and api.token.prefix
Date: Tue, 29 Sep 2020 18:36:16 +0200


> Le 28 sept. 2020 à 14:30, Adela Vais <adela.vais99@gmail.com> a écrit :
> 
> The D skeleton was not properly supporting them.
> 
> * data/skeletons/d.m4, data/skeletons/lalr1.d: Fix it.
> * tests/calc.at: Check it.

Reading this commit, I felt ashamed of the mysterious -2 in all the 
b4_symbol(-2, ...), so I finally decided to make it easier to understand.

commit cd40ec9526df27d0e3e1c2d41e82a3e6a47254d1
Author: Akim Demaille <akim.demaille@gmail.com>
Date:   Tue Sep 29 06:27:31 2020 +0200

    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.

diff --git a/data/skeletons/bison.m4 b/data/skeletons/bison.m4
index ff923610..851524fe 100644
--- a/data/skeletons/bison.m4
+++ b/data/skeletons/bison.m4
@@ -480,16 +480,18 @@ m4_define([b4_symbol_slot],
 
 # 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.
 m4_define([b4_symbol],
-[m4_case([$2],
-         [id],        [b4_symbol_token_kind([$1])],
-         [kind_base], [b4_symbol_kind_base([$1])],
-         [kind],      [b4_symbol_kind([$1])],
-         [slot],      [b4_symbol_slot([$1])],
-         [_b4_symbol($@)])])
+[m4_if([$1], [empty],
+       [b4_symbol([-2], [$2])],
+       [m4_case([$2],
+                [id],        [b4_symbol_token_kind([$1])],
+                [kind_base], [b4_symbol_kind_base([$1])],
+                [kind],      [b4_symbol_kind([$1])],
+                [slot],      [b4_symbol_slot([$1])],
+                [_b4_symbol($@)])])])
 
 
 # b4_symbol_if(NUM, FIELD, IF-TRUE, IF-FALSE)
diff --git a/data/skeletons/c++.m4 b/data/skeletons/c++.m4
index bd267f69..931e220a 100644
--- a/data/skeletons/c++.m4
+++ b/data/skeletons/c++.m4
@@ -192,7 +192,7 @@ m4_define([b4_declare_symbol_enum],
 [[enum symbol_kind_type
       {
         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
 [      };]])
 
@@ -506,7 +506,7 @@ m4_define([b4_public_types_define],
   bool
   ]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>
@@ -522,7 +522,7 @@ m4_define([b4_public_types_define],
 
   // 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
@@ -544,7 +544,7 @@ m4_define([b4_public_types_define],
   ]b4_inline([$1])[void
   ]b4_parser_class[::by_kind::clear ()
   {
-    kind_ = ]b4_symbol(-2, kind)[;
+    kind_ = ]b4_symbol(empty, kind)[;
   }
 
   ]b4_inline([$1])[void
diff --git a/data/skeletons/d.m4 b/data/skeletons/d.m4
index 70264214..fb883df8 100644
--- a/data/skeletons/d.m4
+++ b/data/skeletons/d.m4
@@ -186,7 +186,7 @@ m4_define([b4_token_enum],
 m4_define([b4_token_enums],
 [/* Token kinds.  */
 public enum TokenKind {
-  ]b4_symbol(-2, id)[ = -2,
+  ]b4_symbol(empty, id)[ = -2,
 b4_symbol_foreach([b4_token_enum])dnl
 }
 ])
@@ -227,7 +227,7 @@ m4_define([b4_declare_symbol_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
 [    }
 
diff --git a/data/skeletons/glr.c b/data/skeletons/glr.c
index 3c531149..45d1ca87 100644
--- a/data/skeletons/glr.c
+++ b/data/skeletons/glr.c
@@ -527,7 +527,7 @@ struct yyGLRStateSet {
   /** During nondeterministic operation, yylookaheadNeeds tracks which
    *  stacks have actually needed the current lookahead.  During deterministic
    *  operation, yylookaheadNeeds[0] is not maintained since it would merely
-   *  duplicate yychar != ]b4_symbol(-2, id)[.  */
+   *  duplicate yychar != ]b4_symbol(empty, id)[.  */
   yybool* yylookaheadNeeds;
   YYPTRDIFF_T yysize;
   YYPTRDIFF_T yycapacity;
@@ -811,7 +811,7 @@ yygetToken (int *yycharp][]b4_pure_if([, yyGLRStack* 
yystackp])[]b4_user_formals
 {
   yysymbol_kind_t yytoken;
 ]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([[
 #if YY_EXCEPTIONS
@@ -889,7 +889,7 @@ yyuserAction (yyRuleNum yyn, int yyrhslen, yyGLRStackItem* 
yyvsp,
 # undef YYRECOVERING
 # define YYRECOVERING() (yystackp->yyerrState != 0)
 # undef yyclearin
-# define yyclearin (yychar = ]b4_symbol(-2, id)[)
+# define yyclearin (yychar = ]b4_symbol(empty, id)[)
 # undef YYFILL
 # define YYFILL(N) yyfill (yyvsp, &yylow, (N), yynormal)
 # undef YYBACKUP
@@ -1121,7 +1121,7 @@ yyaddDeferredAction (yyGLRStack* yystackp, YYPTRDIFF_T 
yyk, yyGLRState* yystate,
       yynewOption->yyloc = yylloc;])[
     }
   else
-    yynewOption->yyrawchar = ]b4_symbol(-2, id)[;
+    yynewOption->yyrawchar = ]b4_symbol(empty, id)[;
   yynewOption->yynext = yystate->yysemantics.yyfirstVal;
   yystate->yysemantics.yyfirstVal = yynewOption;
 
@@ -2124,7 +2124,7 @@ yypcontext_expected_tokens (const yyGLRStack* yystackp,
           }
     }
   if (yyarg && yycount == 0 && 0 < yyargn)
-    yyarg[0] = ]b4_symbol(-2, kind)[;
+    yyarg[0] = ]b4_symbol(empty, kind)[;
   return yycount;
 }]])[
 
@@ -2143,7 +2143,7 @@ static yysymbol_kind_t
 yypcontext_token (const yyGLRStack *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;
 }
 
@@ -2162,7 +2162,7 @@ yypcontext_location (const yyGLRStack *yystackp)
 yy_syntax_error_arguments (const yyGLRStack* yystackp,
                            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. */
   int yycount = 0;
   /* 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
        accepted due to an error action in a later state.]])[
   */
-  if (yytoken != ]b4_symbol(-2, kind)[)
+  if (yytoken != ]b4_symbol(empty, kind)[)
     {
       int yyn;
       if (yyarg)
@@ -2322,7 +2322,7 @@ yyrecoverSyntaxError (yyGLRStack* 
yystackp]b4_user_formals[)
         int yyj;
         if (yychar == ]b4_symbol(0, [id])[)
           yyFail (yystackp][]b4_lpure_args[, YY_NULLPTR);
-        if (yychar != ]b4_symbol(-2, id)[)
+        if (yychar != ]b4_symbol(empty, id)[)
           {]b4_locations_if([[
             /* We throw away the lookahead, but the error range
                of the shifted error token must take it into account.  */
@@ -2334,7 +2334,7 @@ yyrecoverSyntaxError (yyGLRStack* 
yystackp]b4_user_formals[)
             yytoken = YYTRANSLATE (yychar);
             yydestruct ("Error: discarding",
                         yytoken, &yylval]b4_locuser_args([&yylloc])[);
-            yychar = ]b4_symbol(-2, id)[;
+            yychar = ]b4_symbol(empty, id)[;
           }
         yytoken = ]b4_yygetToken_call[;
         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"));
 
-  yychar = ]b4_symbol(-2, id)[;
+  yychar = ]b4_symbol(empty, id)[;
   yylval = yyval_default;]b4_locations_if([
   yylloc = yyloc_default;])[
 ]m4_ifdef([b4_initial_action], [
@@ -2485,7 +2485,7 @@ b4_dollar_popdef])[]dnl
               if (yyisShiftAction (yyaction))
                 {
                   YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
-                  yychar = ]b4_symbol(-2, id)[;
+                  yychar = ]b4_symbol(empty, id)[;
                   yyposn += 1;
                   yyglrShift (&yystack, 0, yyaction, yyposn, 
&yylval]b4_locations_if([, &yylloc])[);
                   if (0 < yystack.yyerrState)
@@ -2512,7 +2512,7 @@ b4_dollar_popdef])[]dnl
           YYPTRDIFF_T yys;
 
           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:
 
@@ -2550,11 +2550,11 @@ b4_dollar_popdef])[]dnl
 
           /* 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
-             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
              called twice.  */
           yytoken_to_shift = YYTRANSLATE (yychar);
-          yychar = ]b4_symbol(-2, id)[;
+          yychar = ]b4_symbol(empty, id)[;
           yyposn += 1;
           for (yys = 0; yys < yystack.yytops.yysize; yys += 1)
             {
@@ -2604,7 +2604,7 @@ b4_dollar_popdef])[]dnl
   goto yyreturn;
 
  yyreturn:
-  if (yychar != ]b4_symbol(-2, id)[)
+  if (yychar != ]b4_symbol(empty, id)[)
     yydestruct ("Cleanup: discarding lookahead",
                 YYTRANSLATE (yychar), &yylval]b4_locuser_args([&yylloc])[);
 
diff --git a/data/skeletons/glr.cc b/data/skeletons/glr.cc
index e23702ca..f55da2b6 100644
--- a/data/skeletons/glr.cc
+++ b/data/skeletons/glr.cc
@@ -239,8 +239,8 @@ m4_define([b4_glr_cc_setup],
 # pragma clang diagnostic ignored "-Wc++11-long-long"
 #endif
 
-#undef ]b4_symbol(-2, [id])[
-#define ]b4_symbol(-2, [id])[ 
]b4_namespace_ref[::]b4_parser_class[::token::]b4_symbol(-2, [id])[
+#undef ]b4_symbol(empty, [id])[
+#define ]b4_symbol(empty, [id])[ 
]b4_namespace_ref[::]b4_parser_class[::token::]b4_symbol(empty, [id])[
 #undef ]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])[
@@ -270,7 +270,7 @@ m4_define([b4_undef_symbol_kind],
 # -----------------
 # Remove redirections for glr.c.
 m4_define([b4_glr_cc_cleanup],
-[[#undef ]b4_symbol(-2, [id])[
+[[#undef ]b4_symbol(empty, [id])[
 #undef ]b4_symbol(0, [id])[
 #undef ]b4_symbol(1, [id])[
 
diff --git a/data/skeletons/glr2.cc b/data/skeletons/glr2.cc
index 1bbd623a..9cdad84b 100644
--- a/data/skeletons/glr2.cc
+++ b/data/skeletons/glr2.cc
@@ -90,7 +90,7 @@ typedef 
]b4_namespace_ref[::]b4_parser_class[::symbol_kind_type yysymbol_kind_t;
 # -----------------
 # Remove redirections for glr.c.
 m4_define([b4_glr_cc_cleanup],
-[[#undef ]b4_symbol(-2, [id])[
+[[#undef ]b4_symbol(empty, [id])[
 #undef ]b4_symbol(0, [id])[
 #undef ]b4_symbol(1, [id])[
 #undef ]b4_symbol_prefix[YYEMPTY
@@ -571,7 +571,7 @@ static YYLTYPE yyloc_default][]b4_yyloc_default;])[
 [[#define YYTRANSLATE(YYX)                                \
   (0 <= (YYX) && (YYX) <= ]b4_code_max[                     \
    ? 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
    as returned by yylex.  */
@@ -1026,7 +1026,7 @@ class glr_state_set {
   /** During nondeterministic operation, yylookaheadNeeds tracks which
    *  stacks have actually needed the current lookahead.  During deterministic
    *  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;
 
   /** The last stack we invalidated.  */
@@ -1790,7 +1790,7 @@ public:
 
   ~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",
                   YYTRANSLATE (yychar), &yylval]b4_locations_if([, &yylloc])[);
     popall();
@@ -1841,7 +1841,7 @@ public:
                        glr_state* yyrhs, rule_num yyrule)
   {
     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.setNext(yystate->firstVal());
     if (yystateStack.yytops.lookaheadNeeds(yyk))
@@ -1870,13 +1870,13 @@ public:
 [[    yyparser.error (]b4_locations_if([yylloc, ])[YY_("syntax error"));]],
 [[    {
     yysymbol_kind_t yytoken
-      = yychar == ]b4_namespace_ref::b4_parser_class::token::b4_symbol(-2, id)[
-      ? ]b4_namespace_ref::b4_parser_class::b4_symbol(-2, kind)[
+      = yychar == ]b4_namespace_ref::b4_parser_class::token::b4_symbol(empty, 
id)[
+      ? ]b4_namespace_ref::b4_parser_class::b4_symbol(empty, kind)[
       : YYTRANSLATE (yychar);
     enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
     /* Arguments of yyformat. */
     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
        "expected").  */
     int yycount = 0;
@@ -1904,7 +1904,7 @@ public:
          one exception: it will still contain any token that will not be
          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];
         yyarg[yycount++] = yytoken;
@@ -1983,7 +1983,7 @@ public:
           int yyj;
           if (yychar == 
]b4_namespace_ref::b4_parser_class::token::b4_symbol(0, id)[)
             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([[
               /* We throw away the lookahead, but the error range
                  of the shifted error token must take it into account.  */
@@ -1994,7 +1994,7 @@ public:
               yytoken = YYTRANSLATE (yychar);
               yyparser.yy_destroy_ ("Error: discarding",
                           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[;
           yyj = yypact[firstTopState()->yylrState];
@@ -2159,7 +2159,7 @@ public:
   # undef YYRECOVERING
   # define YYRECOVERING() (yyerrState != 0)
   # 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
   # define YYBACKUP(Token, Value)                                              
\
     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;
 ]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";
 #if YY_EXCEPTIONS
@@ -2788,7 +2788,7 @@ yyparse (]b4_namespace_ref[::]b4_parser_class[& 
yyparser]b4_user_formals[)
 
   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([
   yylloc = yyloc_default;])[
 ]m4_ifdef([b4_initial_action], [
@@ -2839,7 +2839,7 @@ b4_dollar_popdef])[]dnl
               if (yyisShiftAction (yyaction))
                 {
                   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;
                   yystack.yyglrShift (create_state_set_index(0), yyaction, 
yyposn, &yylval]b4_locations_if([, &yylloc])[);
                   if (0 < yystack.yyerrState)
@@ -2864,7 +2864,7 @@ b4_dollar_popdef])[]dnl
           yysymbol_kind_t yytoken_to_shift;
 
           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:
 
@@ -2902,11 +2902,11 @@ b4_dollar_popdef])[]dnl
 
           /* 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
-             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
              called twice.  */
           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;
           for (state_set_index yys = create_state_set_index(0); yys.uget() < 
yystack.yystateStack.numTops(); ++yys)
             {
diff --git a/data/skeletons/lalr1.cc b/data/skeletons/lalr1.cc
index fe8f13d0..5c260d04 100644
--- a/data/skeletons/lalr1.cc
+++ b/data/skeletons/lalr1.cc
@@ -408,7 +408,7 @@ m4_define([b4_shared_declarations],
       void move (by_state& that);
 
       /// 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;
 
       /// 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
   {
     if (state == empty_state)
-      return ]b4_symbol(-2, kind)[;
+      return ]b4_symbol(empty, kind)[;
     else
       return YY_CAST (symbol_kind_type, yystos_[+state]);
   }
@@ -690,7 +690,7 @@ m4_if(b4_prefix, [yy], [],
     b4_symbol_variant([that.kind ()],
                       [value], [move], [YY_MOVE (that.value)])])[
     // that is emptied.
-    that.kind_ = ]b4_symbol(-2, kind)[;
+    that.kind_ = ]b4_symbol(empty, kind)[;
   }
 
 #if YY_CPLUSPLUS < 201103L
@@ -1333,7 +1333,7 @@ b4_dollar_popdef])[]dnl
       }
 ]])[
     if (yyarg && yycount == 0 && 0 < yyargn)
-      yyarg[0] = ]b4_symbol(-2, kind)[;
+      yyarg[0] = ]b4_symbol(empty, kind)[;
     return yycount;
   }
 
diff --git a/data/skeletons/lalr1.d b/data/skeletons/lalr1.d
index e74b2e05..9bbff20f 100644
--- a/data/skeletons/lalr1.d
+++ b/data/skeletons/lalr1.d
@@ -394,9 +394,9 @@ b4_locations_if([, ref ]b4_location_type[ yylocationp])[)
   public bool parse ()
   {
     // Lookahead token kind.
-    int yychar = TokenKind.]b4_symbol(-2, id)[;
+    int yychar = TokenKind.]b4_symbol(empty, id)[;
     // Lookahead symbol kind.
-    SymbolKind yytoken = ]b4_symbol(-2, kind)[;
+    SymbolKind yytoken = ]b4_symbol(empty, kind)[;
 
     /* State.  */
     int yyn = 0;
@@ -459,7 +459,7 @@ m4_popdef([b4_at_dollar])])dnl
         }
 
         /* Read a lookahead token.  */
-        if (yychar == TokenKind.]b4_symbol(-2, id)[)
+        if (yychar == TokenKind.]b4_symbol(empty, id)[)
         {]b4_parse_trace_if([[
           yycdebugln ("Reading a token");]])[
           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])[);]])[
 
             /* 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
              * status.  */
@@ -553,8 +553,8 @@ m4_popdef([b4_at_dollar])])dnl
         if (yyerrstatus_ == 0)
         {
           ++yynerrs_;
-          if (yychar == TokenKind.]b4_symbol(-2, id)[)
-            yytoken = ]b4_symbol(-2, kind)[;
+          if (yychar == TokenKind.]b4_symbol(empty, id)[)
+            yytoken = ]b4_symbol(empty, kind)[;
           yyerror (]b4_locations_if([yylloc, ])[yysyntax_error (yystate, 
yytoken));
         }
 ]b4_locations_if([
@@ -571,7 +571,7 @@ m4_popdef([b4_at_dollar])])dnl
              return false;
           }
           else
-            yychar = TokenKind.]b4_symbol(-2, id)[;
+            yychar = TokenKind.]b4_symbol(empty, id)[;
         }
 
         /* 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
          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
       // with internationalization.
diff --git a/data/skeletons/yacc.c b/data/skeletons/yacc.c
index c9d8161d..cd142055 100644
--- a/data/skeletons/yacc.c
+++ b/data/skeletons/yacc.c
@@ -727,7 +727,7 @@ static const ]b4_int_type_for([b4_toknum])[ yytoknum[] =
 enum { YYENOMEM = -2 };
 
 #define yyerrok         (yyerrstatus = 0)
-#define yyclearin       (yychar = ]b4_symbol(-2, id)[)
+#define yyclearin       (yychar = ]b4_symbol(empty, id)[)
 
 #define YYACCEPT        goto yyacceptlab
 #define YYABORT         goto yyabortlab
@@ -738,7 +738,7 @@ enum { YYENOMEM = -2 };
 
 #define YYBACKUP(Token, Value)                                    \
   do                                                              \
-    if (yychar == ]b4_symbol(-2, id)[)                                        \
+    if (yychar == ]b4_symbol(empty, id)[)                                      
  \
       {                                                           \
         yychar = (Token);                                         \
         yylval = (Value);                                         \
@@ -1206,7 +1206,7 @@ yypcontext_expected_tokens (const yypcontext_t *yyctx,
           }
     }]])[
   if (yyarg && yycount == 0 && 0 < yyargn)
-    yyarg[0] = ]b4_symbol(-2, kind)[;
+    yyarg[0] = ]b4_symbol(empty, kind)[;
   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
        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([[
       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.  */
   int yyresult;
   /* 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
      action routines.  */
   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"));
 
 ]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], [
 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.  */
 
   /* 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([[
       if (!yyps->yynew)
         {]b4_use_push_for_pull_if([], [[
@@ -1876,7 +1876,7 @@ yyread_pushed_token:]])[
   *++yylsp = yylloc;])[
 
   /* Discard the shifted token.  */
-  yychar = ]b4_symbol(-2, id)[;]b4_lac_if([[
+  yychar = ]b4_symbol(empty, id)[;]b4_lac_if([[
   YY_LAC_DISCARD ("shift");]])[
   goto yynewstate;
 
@@ -1967,7 +1967,7 @@ yyreduce:
 yyerrlab:
   /* Make sure we have latest lookahead translation.  See comments at
      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 (!yyerrstatus)
     {
@@ -1977,7 +1977,7 @@ yyerrlab:
 [[      {
         yypcontext_t yyctx
           = {]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;]])[
         if (yyreport_syntax_error (&yyctx]m4_ifset([b4_parse_param],
                                   [[, ]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]])[};
         char const *yymsgp = YY_("syntax error");
         int yysyntax_error_status;]b4_lac_if([[
-        if (yychar != ]b4_symbol(-2, id)[)
+        if (yychar != ]b4_symbol(empty, id)[)
           YY_LAC_ESTABLISH;]])[
         yysyntax_error_status = yysyntax_error (&yymsg_alloc, &yymsg, &yyctx);
         if (yysyntax_error_status == 0)
@@ -2036,7 +2036,7 @@ yyerrlab:
         {
           yydestruct ("Error: discarding",
                       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:
-  if (yychar != ]b4_symbol(-2, id)[)
+  if (yychar != ]b4_symbol(empty, id)[)
     {
       /* Make sure we have latest lookahead translation.  See comments at
          user semantic actions for why this is necessary.  */





reply via email to

[Prev in Thread] Current Thread [Next in Thread]