--- orig/bison-2.0/src/scan-gram.l Sun Aug 8 06:57:06 2004 +++ bison-2.0/src/scan-gram.l Wed May 18 00:53:29 2005 @@ -106,6 +106,12 @@ static int convert_ucn_to_byte (char con static void unexpected_eof (boundary, char const *); static void unexpected_newline (boundary, char const *); +/* Context switch, deciding where the outermost braces "{...}" should be included + in the BRACED_CODE token. */ +bool include_braces = true; + +/* Context switch; true for non-grammar identifiers. */ +bool other_id = false; %} %x SC_COMMENT SC_LINE_COMMENT SC_YACC_COMMENT %x SC_STRING SC_CHARACTER @@ -185,6 +191,7 @@ splice (\\[ \f\t\v]*\n)* "%debug" return PERCENT_DEBUG; "%default"[-_]"prec" return PERCENT_DEFAULT_PREC; "%define" return PERCENT_DEFINE; + "%code" return PERCENT_CODE; "%defines" return PERCENT_DEFINES; "%destructor" token_type = PERCENT_DESTRUCTOR; BEGIN SC_PRE_CODE; "%dprec" return PERCENT_DPREC; @@ -218,6 +225,7 @@ splice (\\[ \f\t\v]*\n)* "%token"[-_]"table" return PERCENT_TOKEN_TABLE; "%type" return PERCENT_TYPE; "%union" token_type = PERCENT_UNION; BEGIN SC_PRE_CODE; + "%typed" return PERCENT_TYPED; "%verbose" return PERCENT_VERBOSE; "%yacc" return PERCENT_YACC; @@ -230,6 +238,13 @@ splice (\\[ \f\t\v]*\n)* ";" return SEMICOLON; {id} { + if (other_id) { + STRING_GROW; + STRING_FINISH; + loc->start = code_start; + val->chars = last_string; + return OTHER_ID; + } val->symbol = symbol_get (yytext, *loc); id_loc = *loc; rule_length++; @@ -256,7 +271,8 @@ splice (\\[ \f\t\v]*\n)* /* Code in between braces. */ "{" { - STRING_GROW; + if (include_braces) + STRING_GROW; token_type = BRACED_CODE; braces_level = 0; code_start = loc->start; @@ -574,10 +590,11 @@ splice (\\[ \f\t\v]*\n)* should also diagnose other Bison extensions like %yacc. Perhaps there should also be a GCC-style --pedantic-errors option, so that such warnings are diagnosed as errors. */ - if (outer_brace && token_type == BRACED_CODE && ! yacc_flag) + if (include_braces && outer_brace && token_type == BRACED_CODE && ! yacc_flag) obstack_1grow (&obstack_for_string, ';'); - obstack_1grow (&obstack_for_string, '}'); + if (include_braces || !outer_brace) + obstack_1grow (&obstack_for_string, '}'); if (outer_brace) {