From: Vern Paxson Date: Thu, 16 Sep 1993 20:27:27 +0000 (+0000) Subject: Fixed bugs regarding %{%} code in section 2 prolog X-Git-Tag: flex-2-5-5b~410 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=77210a1d93980ae1fcaa2ce34d1de42780aea2fb;p=flex Fixed bugs regarding %{%} code in section 2 prolog %array not allowed with C++ scanners --- diff --git a/scan.l b/scan.l index 53b7792..0099043 100644 --- a/scan.l +++ b/scan.l @@ -107,12 +107,19 @@ CCL_CHAR [^\\\n\]]|{ESCSEQ} ^"%%".* { sectnum = 2; line_directive_out( stdout ); + bracelevel = 0; BEGIN(SECT2PROLOG); return SECTEND; } ^"%pointer".*{NL} ++linenum; yytext_is_array = false; -^"%array".*{NL} ++linenum; yytext_is_array = true; +^"%array".*{NL} { + if ( C_plus_plus ) + warn( "%array incompatible with -+ option" ); + else + yytext_is_array = true; + ++linenum; + } ^"%used" { warn( "%used/%unused have been deprecated" ); @@ -204,14 +211,24 @@ CCL_CHAR [^\\\n\]]|{ESCSEQ} {NOT_WS}+ synerr( "unrecognized %used/%unused construct" ); -.*{NL}/{NOT_WS} { - ++linenum; - ACTION_ECHO; - MARK_END_OF_PROLOG; - BEGIN(SECT2); +^"%{".* ++bracelevel; yyless( 2 ); /* eat only %{ */ +^"%}".* --bracelevel; yyless( 2 ); /* eat only %} */ + +^{WS}.* ACTION_ECHO; /* indented code in prolog */ + +^{NOT_WS}.* { /* non-indented code */ + if ( bracelevel <= 0 ) + { /* not in %{ ... %} */ + yyless( 0 ); /* put it all back */ + MARK_END_OF_PROLOG; + BEGIN(SECT2); + } + else + ACTION_ECHO; } -.*{NL} ++linenum; ACTION_ECHO; +.* ACTION_ECHO; +{NL} ++linenum; ACTION_ECHO; <> { MARK_END_OF_PROLOG;