bison-patches
[Top][All Lists]
Advanced

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

bison.c++ catch up


From: Akim Demaille
Subject: bison.c++ catch up
Date: 28 May 2002 11:53:45 +0200
User-agent: Gnus/5.0808 (Gnus v5.8.8) XEmacs/21.4 (Honest Recruiter)

Index: ChangeLog
from  Akim Demaille  <address@hidden>

        * data/bison.c++: Catch up with bison.simple:
        2002-05-24  Paul Hilfinger  <address@hidden>
        and Paul Eggert  <address@hidden>: `error' handing.
        2002-05-26  Akim Demaille  <address@hidden>: stos_, token_number_,
        and popping traces.

Index: data/bison.c++
===================================================================
RCS file: /cvsroot/bison/bison/data/bison.c++,v
retrieving revision 1.31
diff -u -u -r1.31 bison.c++
--- data/bison.c++ 20 May 2002 22:56:53 -0000 1.31
+++ data/bison.c++ 28 May 2002 09:52:24 -0000
@@ -272,6 +272,8 @@
     static const RhsNumberType rhs_[[]];
     static const b4_uint_type(b4_prhs_max) prhs_[[]];
     static const b4_uint_type(b4_rline_max) rline_[[]];
+    static const b4_uint_type(b4_stos_max) stos_[[]];
+    static const short token_number_[[]];
 #endif
 
     /* Even more tables.  */
@@ -567,47 +569,62 @@
      token.  */
 
   errstatus = 3;
-  goto yyerrhandle;
 
-  /* Pop the current state because it cannot handle the error token.  */
- yyerrdefault:
- yyerrpop:
-  if (!state_stack_.height ())
-    goto yyabortlab;
-  state_ = (state_stack_.pop (), state_stack_[[0]]);
-  semantic_stack_.pop ();
-  location_stack_.pop ();;
+  for (;;)
+    {
+      n_ = pact_[[state_]];
+      if (n_ != flag_)
+       {
+         n_ += terror_;
+         if (0 <= n_ && n_ <= last_ && check_[[n_]] == terror_)
+           {
+             n_ = table_[[n_]];
+             if (0 < n_)
+               break;
+           }
+       }
+
+      /* Pop the current state because it cannot handle the error token.  */
+      if (!state_stack_.height ())
+       goto yyabortlab;
 
 #if YYDEBUG
-  if (debug_)
-    {
-      YYFPRINTF (stderr, "Error: state stack now");
-      for (StateStack::ConstIterator i = state_stack_.begin ();
-          i != state_stack_.end (); ++i)
-       YYFPRINTF (stderr, " %d", *i);
-      YYFPRINTF (stderr, "\n");
-    }
+      if (debug_)
+       {
+         if (stos_[[state_]] < ntokens_)
+           {
+             YYFPRINTF (stderr, "Error: popping token %d (%s",
+                        token_number_[[stos_[state_]]],
+                        name_[[stos_[state_]]]);
+# ifdef YYPRINT
+             YYPRINT (stderr, token_number_[[stos_[state_]]],
+                      semantic_stack_.top ());
+# endif
+             YYFPRINTF (stderr, ")\n");
+           }
+         else
+           {
+             YYFPRINTF (stderr, "Error: popping nonterminal (%s)\n",
+                        name_[[stos_[state_]]]);
+           }
+       }
 #endif
 
- yyerrhandle:
-  n_ = pact_[[state_]];
-  if (n_ == flag_)
-    goto yyerrdefault;
-
-  n_ += terror_;
-  if (n_ < 0 || n_ > last_ || check_[[n_]] != terror_)
-    goto yyerrdefault;
+      state_ = (state_stack_.pop (), state_stack_[[0]]);
+      semantic_stack_.pop ();
+      location_stack_.pop ();;
 
-  n_ = table_[[n_]];
-  if (n_ < 0)
-    {
-      if (n_ == flag_)
-       goto yyerrpop;
-      n_ = -n_;
-      goto yyreduce;
+#if YYDEBUG
+      if (debug_)
+       {
+         YYFPRINTF (stderr, "Error: state stack now");
+         for (StateStack::ConstIterator i = state_stack_.begin ();
+              i != state_stack_.end (); ++i)
+           YYFPRINTF (stderr, " %d", *i);
+         YYFPRINTF (stderr, "\n");
+       }
+#endif
     }
-  else if (!n_)
-    goto yyerrpop;
 
   if (n_ == final_)
     goto yyacceptlab;
@@ -685,6 +702,24 @@
 {
   b4_check
 };
+
+#if YYDEBUG
+/* STOS_[[STATE-NUM]] -- The (internal number of the) accessing
+   symbol of state STATE-NUM.  */
+const b4_uint_type(b4_stos_max)
+yy::b4_name::stos_[[]] =
+{
+  b4_stos
+};
+
+/* TOKEN_NUMBER_[[YYLEX-NUM]] -- Internal token number corresponding
+   to YYLEX-NUM.  */
+const short
+yy::b4_name::token_number_[[]] =
+{
+  b4_toknum
+};
+#endif
 
 /* YYR1[[YYN]] -- Symbol number of symbol that rule YYN derives.  */
 const b4_uint_type(b4_r1_max)
Index: data/bison.simple
===================================================================
RCS file: /cvsroot/bison/bison/data/bison.simple,v
retrieving revision 1.28
diff -u -u -r1.28 bison.simple
--- data/bison.simple 26 May 2002 18:38:41 -0000 1.28
+++ data/bison.simple 28 May 2002 09:52:24 -0000
@@ -371,7 +371,8 @@
 };
 #endif
 
-/* YYTOKNUM[[YYN]] -- Index in YYTNAME corresponding to YYLEX.  */
+/* YYTOKNUM[[YYLEX-NUM]] -- Internal token number corresponding to
+   token YYLEX-NUM.  */
 static const short yytoknum[[]] =
 {
   b4_toknum



reply via email to

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