]> granicus.if.org Git - flex/commitdiff
RCS header
authorVern Paxson <vern@ee.lbl.gov>
Sun, 8 May 1988 20:06:39 +0000 (20:06 +0000)
committerVern Paxson <vern@ee.lbl.gov>
Sun, 8 May 1988 20:06:39 +0000 (20:06 +0000)
bug fix due to missing default rule, could have to backtrack when
  backtrack variables haven't been set up

parse.y

diff --git a/parse.y b/parse.y
index e11640733fe755423ccb51fab0b0651d9e002feb..d9cf7beca26cc5e72c030a25928a487f4ff13a9f 100644 (file)
--- a/parse.y
+++ b/parse.y
 %token CHAR NUMBER SECTEND SCDECL XSCDECL WHITESPACE NAME PREVCCL
 
 %{
+
 #include "flexdef.h"
 
+#ifndef lint
+static char rcsid[] =
+    "@(#) $Header$ (LBL)";
+#endif
+
 int pat, scnum, eps, headcnt, trailcnt, anyccl, lastchar, i, actvp, rulelen;
 int trlcontxt, xcluflg, cclsorted, varlength;
 char clower();
@@ -27,6 +33,22 @@ static int madeany = false;  /* whether we've made the '.' character class */
 
 %%
 goal            :  initlex sect1 sect1end sect2
+                       { /* add default rule */
+                       int def_rule;
+
+                       pat = cclinit();
+                       cclnegate( pat );
+
+                       def_rule = mkstate( -pat );
+
+                       add_accept( def_rule, 0, 0 );
+
+                       for ( i = 1; i <= lastsc; ++i )
+                           scset[i] = mkbranch( scset[i], def_rule );
+
+                       fputs( "YY_DEFAULT_ACTION;\n\tYY_BREAK\n",
+                              temp_action_file );
+                       }
                ;
 
 initlex         :
@@ -89,7 +111,8 @@ flexrule        :  scon '^' re eol
                        add_accept( pat, headcnt, trailcnt );
 
                        for ( i = 1; i <= actvp; ++i )
-                           scbol[actvsc[i]] = mkbranch( scbol[actvsc[i]], pat );
+                           scbol[actvsc[i]] =
+                               mkbranch( scbol[actvsc[i]], pat );
                        }
 
                |  scon re eol 
@@ -98,7 +121,8 @@ flexrule        :  scon '^' re eol
                        add_accept( pat, headcnt, trailcnt );
 
                        for ( i = 1; i <= actvp; ++i )
-                           scset[actvsc[i]] = mkbranch( scset[actvsc[i]], pat );
+                           scset[actvsc[i]] = 
+                               mkbranch( scset[actvsc[i]], pat );
                        }
 
                 |  '^' re eol