bison-patches
[Top][All Lists]
Advanced

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

GLR's traces


From: Akim Demaille
Subject: GLR's traces
Date: 13 Oct 2002 16:18:15 +0200
User-agent: Gnus/5.0808 (Gnus v5.8.8) XEmacs/21.4 (Honest Recruiter)

Index: ChangeLog
from  Akim Demaille  <address@hidden>

        * data/glr.c: Formatting changes.
        Tweak some trace messages to match yacc.c's.

Index: data/glr.c
--- data/glr.c Sun, 13 Oct 2002 16:03:02 +0200 akim
+++ data/glr.c Sun, 13 Oct 2002 16:15:20 +0200 akim
@@ -693,7 +693,7 @@ m4_define_default([b4_header_guard],
   return yydefact[yystate];
 }

-/** Set *ACTION to the action to take in STATE on seeing TOKEN.
+/** Set *YYACTION to the action to take in YYSTATE on seeing YYTOKEN.
  *  Result R means
  *    R < 0:  Reduce on rule -R.
  *    R = 0:  Error.
@@ -1069,13 +1069,25 @@ m4_define_default([b4_header_guard],
       YYSTYPE yysval;
       YYLTYPE yyloc;

+#if YYDEBUG
+      if (yydebug)
+       {
+         int yyi;
+         YYDPRINTF ((stderr, "Reducing stack %d by rule %d (line %d),",
+                     yyk, yyrule - 1, yyrline[yyrule]));
+         /* Print the symbols being reduced, and their result.  */
+         for (yyi = yyprhs[yyrule]; yyrhs[yyi] >= 0; yyi++)
+           YYFPRINTF (stderr, "%s ", yytokenName (yyrhs[yyi]));
+         YYFPRINTF (stderr, " -> %s\n", yytokenName (yyr1[yyrule]));
+       }
+#endif
       YYCHK (yydoAction (yystack, yyk, yyrule, &yysval, &yyloc));
       yyglrShift (yystack, yyk,
                  yyLRgotoState (yystack->yytops.yystates[yyk]->yylrState,
                                 yylhsNonterm (yyrule)),
                yyposn, yysval, &yyloc);
-      YYDPRINTF ((stderr, "Reduced stack %d by rule #%d. Now in state %d.\n",
-                 yyk, yyrule-1, yystack->yytops.yystates[yyk]->yylrState));
+      YYDPRINTF ((stderr, "Stack %d entering state %d\n",
+                 yyk, yystack->yytops.yystates[yyk]->yylrState));
     }
   else
     {
@@ -1454,9 +1466,11 @@ m4_define_default([b4_header_guard],
        {
          if (*yytokenp == YYEMPTY)
            {
+             YYDPRINTF ((stderr, "Reading a token: "));
              yychar = YYLEX;
              *yytokenp = YYTRANSLATE(yychar);
-             YYDPRINTF ((stderr, "Read token %s\n", yytokenName (*yytokenp)));
+             YYDPRINTF ((stderr, "Next token is %s\n",
+                         yytokenName (*yytokenp)));
            }
          yygetLRActions (yystate, *yytokenp, &yyaction, &yyconflicts);

@@ -1473,7 +1487,7 @@ m4_define_default([b4_header_guard],

          if (yyisShiftAction (yyaction))
            {
-             YYDPRINTF ((stderr, "Shifted token %s on stack %d, ",
+             YYDPRINTF ((stderr, "Shifting token %s on stack %d, ",
                          yytokenName (*yytokenp), yyk));
              yyglrShift (yystack, yyk, yyaction, yyposn+1, *yylvalp, yyllocp);
              YYDPRINTF ((stderr, "which is now in state #%d\n",
@@ -1559,21 +1573,22 @@ m4_define_default([b4_header_guard],
   if (yystack->yyerrState == 0)
     yystack->yyerrState = 3;
   else if (yystack->yyerrState == 3)
-    {
-      /* We just shifted the error token and (perhaps) took some
-        reductions. Skip tokens until we can proceed. */
-      do {
+    /* We just shifted the error token and (perhaps) took some
+       reductions.  Skip tokens until we can proceed.  */
+    while (yytrue)
+      {
        if (*yytokenp == YYEOF)
          yyFail (yystack, NULL);
        if (*yytokenp != YYEMPTY)
          YYDPRINTF ((stderr, "Discarding token %s\n",
                      yytokenName (*yytokenp)));
+       YYDPRINTF ((stderr, "Reading a token: "));
        yychar = YYLEX;
        *yytokenp = YYTRANSLATE (yychar);
-       YYDPRINTF ((stderr, "Read token %s\n", yytokenName (*yytokenp)));
+       YYDPRINTF ((stderr, "Next token is %s\n", yytokenName (*yytokenp)));
        yyj = yypact[yystack->yytops.yystates[0]->yylrState];
        if (yyj == YYPACT_NINF)
-         /* Something's not right; we shouldn't be here */
+         /* Something's not right; we shouldn't be here.  */
          yyFail (yystack, NULL);
        yyj += *yytokenp;
        if (yyj < 0 || yyj > YYLAST || yycheck[yyj] != *yytokenp)
@@ -1583,10 +1598,9 @@ m4_define_default([b4_header_guard],
          }
        else if (yytable[yyj] != 0 && yytable[yyj] != YYTABLE_NINF)
          return;
-      } while (yytrue);
-    }
+      }

-  /* Reduce to one stack */
+  /* Reduce to one stack.  */
   for (yyk = 0; yyk < yystack->yytops.yysize; yyk += 1)
     if (yystack->yytops.yystates[yyk] != NULL)
       break;
@@ -1652,6 +1666,8 @@ m4_define_default([b4_header_guard],
   yyinitGLRStack (&yystack, YYINITDEPTH);
   yystack.yytokenp = &yytoken;

+  YYDPRINTF ((stderr, "Starting parse\n"));
+
   if (setjmp (yystack.yyexception_buffer) != 0)
     goto yyDone;

@@ -1689,9 +1705,10 @@ m4_define_default([b4_header_guard],
            {
              if (yytoken == YYEMPTY)
                {
+                 YYDPRINTF ((stderr, "Reading a token: "));
                  yychar = YYLEX;
                  yytoken = YYTRANSLATE (yychar);
-                 YYDPRINTF ((stderr, "Read token %s\n",
+                 YYDPRINTF ((stderr, "Next token is %s\n",
                              yytokenName (yytoken)));
                }
              yygetLRActions (yystate, yytoken, &yyaction, &yyconflicts);
@@ -1699,7 +1716,7 @@ m4_define_default([b4_header_guard],
                break;
              if (yyisShiftAction (yyaction))
                {
-                 YYDPRINTF ((stderr, "Shifted token %s. ",
+                 YYDPRINTF ((stderr, "Shifting token %s, ",
                              yytokenName (yytoken)));
                  if (yytoken != YYEOF)
                    yytoken = YYEMPTY;
@@ -1707,7 +1724,7 @@ m4_define_default([b4_header_guard],
                  yyglrShift (&yystack, 0, yyaction, yyposn, yylval, yyllocp);
                  if (yystack.yyerrState > 0)
                    yystack.yyerrState -= 1;
-                 YYDPRINTF ((stderr, "Now in state #%d\n",
+                 YYDPRINTF ((stderr, "Entering state %d\n",
                              yystack.yytops.yystates[0]->yylrState));
                }
              else if (yyisErrorAction (yyaction))




reply via email to

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