]> git.saurik.com Git - bison.git/commitdiff
yychar cannot be empty in yyerrlab.
authorAkim Demaille <demaille@gostai.com>
Mon, 18 Aug 2008 19:31:06 +0000 (21:31 +0200)
committerAkim Demaille <demaille@gostai.com>
Tue, 11 Nov 2008 14:26:17 +0000 (15:26 +0100)
* TODO (yychar == yyempty_): New.
* data/lalr1.cc: Remove the handling of this case.
This eases forthcoming changes related to yychar and yytranslate.

ChangeLog
TODO
data/lalr1.cc

index 17023e24e053870e5e7e38989b621144cb50c7b8..e8e8ac2bcba56dfc7e33aac47c5cdb622fdd560f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2008-11-11  Akim Demaille  <demaille@gostai.com>
+
+       yychar cannot be empty in yyerrlab.
+       * TODO (yychar == yyempty_): New.
+       * data/lalr1.cc: Remove the handling of this case.
+       This eases forthcoming changes related to yychar and yytranslate.
+
 2008-11-11  Akim Demaille  <demaille@gostai.com>
 
        Bench: syntactic sugar for %define/#define.
diff --git a/TODO b/TODO
index 7b473094cf7d7450ea66b48e618f7ead857d6465..918ca350589676dd9ff0dff7a67fb1c91d2d564a 100644 (file)
--- a/TODO
+++ b/TODO
@@ -54,6 +54,22 @@ what it should look like.  For instance what follows crashes.
     return yyparse ();
   }
 
+** yychar == yyempty_
+The code in yyerrlab reads:
+
+      if (yychar <= YYEOF)
+       {
+         /* Return failure if at end of input.  */
+         if (yychar == YYEOF)
+           YYABORT;
+       }
+
+There are only two yychar that can be <= YYEOF: YYEMPTY and YYEOF.
+But I can't produce the situation where yychar is YYEMPTY here, is it
+really possible?  The test suite does not exercise this case.
+
+This shows that it would be interesting to manage to install skeleton
+coverage analysis to the test suite.
 
 * Header guards
 
index 4915caa245f55e49d035c5aa4bc9d9a6361929aa..8c5b33450d19cc3006e9cc7ab7658743059cf1d6 100644 (file)
@@ -1281,18 +1281,19 @@ m4_ifdef([b4_lex_param], [, ]b4_lex_param))[;
     if (yyerrstatus_ == 3)
       {
        /* If just tried and failed to reuse lookahead token after an
-        error, discard it.  */
-
-       if (yychar <= yyeof_)
-         {
-            /* Return failure if at end of input.  */
-            if (yychar == yyeof_)
-              YYABORT;
-         }
-       else
-         {
-           yy_destroy_ ("Error: discarding", yyla);
-           yychar = yyempty_;
+           error, discard it.  */
+
+        /* Return failure if at end of input.  */
+        if (yychar == yyeof_)
+          YYABORT;
+        else
+          {]b4_assert_if([
+            // Previous version of this code was ready to handle
+            // yychar == yyempty_ (actually yychar <= yyeof_).  Can it
+            // really be triggered?
+            assert (yychar != yyempty_);])[
+            yy_destroy_ ("Error: discarding", yyla);
+            yychar = yyempty_;
          }
       }