From: Vern Paxson Date: Sun, 8 May 1988 20:06:39 +0000 (+0000) Subject: RCS header X-Git-Tag: flex-2-5-5b~631 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=32fe716b3738f3305606140d5676d5376e22c277;p=flex RCS header bug fix due to missing default rule, could have to backtrack when backtrack variables haven't been set up --- diff --git a/parse.y b/parse.y index e116407..d9cf7be 100644 --- a/parse.y +++ b/parse.y @@ -15,8 +15,14 @@ %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