bison-patches
[Top][All Lists]
Advanced

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

{master}: glr: simplify the invocation of YYLLOC_DEFAULT


From: Akim Demaille
Subject: {master}: glr: simplify the invocation of YYLLOC_DEFAULT
Date: Thu, 19 Sep 2013 16:23:54 +0200

Ongoing work has led me to check this area of the code.
I see no good reason for the extra belts around the call
to LLOC_DEFAULT.

It was introduced by Joel in
http://lists.gnu.org/archive/html/bison-patches/2006-03/msg00008.html


From 55a206300587164154dc565abe0b7e28294a8c3e Mon Sep 17 00:00:00 2001
From: Akim Demaille <address@hidden>
Date: Thu, 19 Sep 2013 16:00:10 +0200
Subject: [PATCH] glr: simplify the invocation of YYLLOC_DEFAULT

The commit which introduces yyresolveLocations (commit
8710fc41aaebc5d167a2783a4b8b60849a803869) saves and restores the
look-ahead (type, value and location) for no clear reason.  This
appears to be useless.

* data/glr.c (yyresolveLocations): Don't save/restore the current
look-ahead to call YYLLOC_DEFAULT.
Minor style changes.
---
 data/glr.c | 19 ++++---------------
 1 file changed, 4 insertions(+), 15 deletions(-)

diff --git a/data/glr.c b/data/glr.c
index ff70890..895a69e 100644
--- a/data/glr.c
+++ b/data/glr.c
@@ -1661,7 +1661,7 @@ yyreportAmbiguity (yySemanticOption* yyx0,
  *  ending at YYS1.  Has no effect on previously resolved states.
  *  The first semantic option of a state is always chosen.  */
 static void
-yyresolveLocations (yyGLRState* yys1, int yyn1,
+yyresolveLocations (yyGLRState *yys1, int yyn1,
                     yyGLRStack *yystackp]b4_user_formals[)
 {
   if (0 < yyn1)
@@ -1672,9 +1672,9 @@ yyresolveLocations (yyGLRState* yys1, int yyn1,
           yyGLRStackItem yyrhsloc[1 + YYMAXRHS];
           int yynrhs;
           yySemanticOption *yyoption = yys1->yysemantics.yyfirstVal;
-          YYASSERT (yyoption != YY_NULL);
+          YYASSERT (yyoption);
           yynrhs = yyrhsLength (yyoption->yyrule);
-          if (yynrhs > 0)
+          if (0 < yynrhs)
             {
               yyGLRState *yys;
               int yyn;
@@ -1697,18 +1697,7 @@ yyresolveLocations (yyGLRState* yys1, int yyn1,
               yyGLRState *yyprevious = yyoption->yystate;
               yyrhsloc[0].yystate.yyloc = yyprevious->yyloc;
             }
-          {
-            int yychar_current = yychar;
-            YYSTYPE yylval_current = yylval;
-            YYLTYPE yylloc_current = yylloc;
-            yychar = yyoption->yyrawchar;
-            yylval = yyoption->yyval;
-            yylloc = yyoption->yyloc;
-            YYLLOC_DEFAULT ((yys1->yyloc), yyrhsloc, yynrhs);
-            yychar = yychar_current;
-            yylval = yylval_current;
-            yylloc = yylloc_current;
-          }
+          YYLLOC_DEFAULT ((yys1->yyloc), yyrhsloc, yynrhs);
         }
     }
 }]])[
-- 
1.8.4





reply via email to

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