From: Paul Eggert Date: Tue, 5 Nov 2002 23:50:11 +0000 (+0000) Subject: (braces_level): Now auto, not static. X-Git-Tag: BISON-1_875~342 X-Git-Url: https://git.saurik.com/bison.git/commitdiff_plain/1a9e39f116a7db196e75459aca8eb671fbabb4c7 (braces_level): Now auto, not static. Initialize to zero if the compiler is being picky. (INITIAL): Clear braces_level instead of incrementing it. (SC_BRACED_CODE): Treat <% and %> as { and } when inside C code, as POSIX 1003.1-2001 requires. --- diff --git a/src/scan-gram.l b/src/scan-gram.l index e8620646..3e8ae487 100644 --- a/src/scan-gram.l +++ b/src/scan-gram.l @@ -163,7 +163,6 @@ scanner_last_string_free (void) } -static int braces_level = 0; static int percent_percent_count = 0; /* Within well-formed rules, RULE_LENGTH is the number of values in @@ -202,6 +201,8 @@ splice (\\[ \f\t\v]*\n)* %% %{ + int braces_level IF_LINT (= 0); + /* At each yylex invocation, mark the current position as the start of the next token. */ YY_STEP; @@ -294,7 +295,7 @@ splice (\\[ \f\t\v]*\n)* "%{" yy_push_state (SC_PROLOGUE); /* Code in between braces. */ - "{" YY_OBS_GROW; ++braces_level; yy_push_state (SC_BRACED_CODE); + "{" YY_OBS_GROW; braces_level = 0; yy_push_state (SC_BRACED_CODE); /* A type. */ "<"{tag}">" { @@ -583,9 +584,12 @@ splice (\\[ \f\t\v]*\n)* { + "{"|"<"{splice}"%" YY_OBS_GROW; braces_level++; + "%"{splice}">" YY_OBS_GROW; braces_level--; "}" { YY_OBS_GROW; - if (--braces_level == 0) + braces_level--; + if (braces_level < 0) { yy_pop_state (); YY_OBS_FINISH; @@ -595,17 +599,14 @@ splice (\\[ \f\t\v]*\n)* } } - "{" YY_OBS_GROW; braces_level++; - "$"("<"{tag}">")?(-?[0-9]+|"$") { handle_dollar (current_braced_code, yytext, *yylloc); } "@"(-?[0-9]+|"$") { handle_at (current_braced_code, yytext, *yylloc); } - [^$@\[\]/\'\"\{\}]+ YY_OBS_GROW; - - /* A stray $, or /, or etc. */ - . YY_OBS_GROW; + /* `"<"{splice}"<"' tokenizes `<<%' correctly (as `<<' `%') rather + than incorrrectly (as `<' `<%'). */ + [^\"$%\'/<@\[\]\{\}]+|[$%/<@]|"<"{splice}"<" YY_OBS_GROW; <> { complain_at (*yylloc, _("unexpected end of file in a braced code"));