* src/scan-gram.l: No longer "parse" things after `%union' until

`{'.  Rather, return a single "%union" token.
No longer make symbols: return strings, and leave the conversion
to symbols to the parser.
(SC_PRE_CODE, token_type): Remove.
* src/parse-gram.y (%union): New field `character'.
Sort tokens.
(CHAR): New token.
(ID, ID_COLON): Now that the scanner no longer makes them
identifiers, adjust all uses to invoke symbol_get.
(id_colon): New, wraps the conversion from string to symbol.
(%union): Accept a possible union_name.
(symbol): Now can be a char.
* data/c.m4 (b4_union_name): Leave a default value.
* data/glr.c, data/yacc.c: Use it.
This commit is contained in:
Akim Demaille
2006-06-19 16:49:44 +00:00
parent 40637e8169
commit 58d7a1a1c7
5 changed files with 707 additions and 661 deletions

View File

@@ -1,3 +1,21 @@
2006-06-19 Akim Demaille <akim@epita.fr>
* src/scan-gram.l: No longer "parse" things after `%union' until
`{'. Rather, return a single "%union" token.
No longer make symbols: return strings, and leave the conversion
to symbols to the parser.
(SC_PRE_CODE, token_type): Remove.
* src/parse-gram.y (%union): New field `character'.
Sort tokens.
(CHAR): New token.
(ID, ID_COLON): Now that the scanner no longer makes them
identifiers, adjust all uses to invoke symbol_get.
(id_colon): New, wraps the conversion from string to symbol.
(%union): Accept a possible union_name.
(symbol): Now can be a char.
* data/c.m4 (b4_union_name): Leave a default value.
* data/glr.c, data/yacc.c: Use it.
2006-06-11 Joel E. Denny <jdenny@ces.clemson.edu> 2006-06-11 Joel E. Denny <jdenny@ces.clemson.edu>
For associating token numbers with token names for "yacc.c", don't use For associating token numbers with token names for "yacc.c", don't use

File diff suppressed because it is too large Load Diff

View File

@@ -47,48 +47,49 @@
PERCENT_TYPE = 262, PERCENT_TYPE = 262,
PERCENT_DESTRUCTOR = 263, PERCENT_DESTRUCTOR = 263,
PERCENT_PRINTER = 264, PERCENT_PRINTER = 264,
PERCENT_UNION = 265, PERCENT_LEFT = 265,
PERCENT_LEFT = 266, PERCENT_RIGHT = 266,
PERCENT_RIGHT = 267, PERCENT_NONASSOC = 267,
PERCENT_NONASSOC = 268, PERCENT_PREC = 268,
PERCENT_PREC = 269, PERCENT_DPREC = 269,
PERCENT_DPREC = 270, PERCENT_MERGE = 270,
PERCENT_MERGE = 271, PERCENT_DEBUG = 271,
PERCENT_DEBUG = 272, PERCENT_DEFAULT_PREC = 272,
PERCENT_DEFAULT_PREC = 273, PERCENT_DEFINE = 273,
PERCENT_DEFINE = 274, PERCENT_DEFINES = 274,
PERCENT_DEFINES = 275, PERCENT_ERROR_VERBOSE = 275,
PERCENT_ERROR_VERBOSE = 276, PERCENT_EXPECT = 276,
PERCENT_EXPECT = 277, PERCENT_EXPECT_RR = 277,
PERCENT_EXPECT_RR = 278, PERCENT_FILE_PREFIX = 278,
PERCENT_FILE_PREFIX = 279, PERCENT_GLR_PARSER = 279,
PERCENT_GLR_PARSER = 280, PERCENT_INITIAL_ACTION = 280,
PERCENT_INITIAL_ACTION = 281, PERCENT_LEX_PARAM = 281,
PERCENT_LEX_PARAM = 282, PERCENT_LOCATIONS = 282,
PERCENT_LOCATIONS = 283, PERCENT_NAME_PREFIX = 283,
PERCENT_NAME_PREFIX = 284, PERCENT_NO_DEFAULT_PREC = 284,
PERCENT_NO_DEFAULT_PREC = 285, PERCENT_NO_LINES = 285,
PERCENT_NO_LINES = 286, PERCENT_NONDETERMINISTIC_PARSER = 286,
PERCENT_NONDETERMINISTIC_PARSER = 287, PERCENT_OUTPUT = 287,
PERCENT_OUTPUT = 288, PERCENT_PARSE_PARAM = 288,
PERCENT_PARSE_PARAM = 289, PERCENT_PURE_PARSER = 289,
PERCENT_PURE_PARSER = 290, PERCENT_REQUIRE = 290,
PERCENT_REQUIRE = 291, PERCENT_SKELETON = 291,
PERCENT_SKELETON = 292, PERCENT_START = 292,
PERCENT_START = 293, PERCENT_TOKEN_TABLE = 293,
PERCENT_TOKEN_TABLE = 294, PERCENT_VERBOSE = 294,
PERCENT_VERBOSE = 295, PERCENT_YACC = 295,
PERCENT_YACC = 296, BRACED_CODE = 296,
TYPE = 297, CHAR = 297,
EQUAL = 298, EPILOGUE = 298,
SEMICOLON = 299, EQUAL = 299,
PIPE = 300, ID = 300,
ID = 301, ID_COLON = 301,
ID_COLON = 302, PERCENT_PERCENT = 302,
PERCENT_PERCENT = 303, PIPE = 303,
PROLOGUE = 304, PROLOGUE = 304,
EPILOGUE = 305, SEMICOLON = 305,
BRACED_CODE = 306 TYPE = 306,
PERCENT_UNION = 307
}; };
#endif #endif
/* Tokens. */ /* Tokens. */
@@ -100,48 +101,49 @@
#define PERCENT_TYPE 262 #define PERCENT_TYPE 262
#define PERCENT_DESTRUCTOR 263 #define PERCENT_DESTRUCTOR 263
#define PERCENT_PRINTER 264 #define PERCENT_PRINTER 264
#define PERCENT_UNION 265 #define PERCENT_LEFT 265
#define PERCENT_LEFT 266 #define PERCENT_RIGHT 266
#define PERCENT_RIGHT 267 #define PERCENT_NONASSOC 267
#define PERCENT_NONASSOC 268 #define PERCENT_PREC 268
#define PERCENT_PREC 269 #define PERCENT_DPREC 269
#define PERCENT_DPREC 270 #define PERCENT_MERGE 270
#define PERCENT_MERGE 271 #define PERCENT_DEBUG 271
#define PERCENT_DEBUG 272 #define PERCENT_DEFAULT_PREC 272
#define PERCENT_DEFAULT_PREC 273 #define PERCENT_DEFINE 273
#define PERCENT_DEFINE 274 #define PERCENT_DEFINES 274
#define PERCENT_DEFINES 275 #define PERCENT_ERROR_VERBOSE 275
#define PERCENT_ERROR_VERBOSE 276 #define PERCENT_EXPECT 276
#define PERCENT_EXPECT 277 #define PERCENT_EXPECT_RR 277
#define PERCENT_EXPECT_RR 278 #define PERCENT_FILE_PREFIX 278
#define PERCENT_FILE_PREFIX 279 #define PERCENT_GLR_PARSER 279
#define PERCENT_GLR_PARSER 280 #define PERCENT_INITIAL_ACTION 280
#define PERCENT_INITIAL_ACTION 281 #define PERCENT_LEX_PARAM 281
#define PERCENT_LEX_PARAM 282 #define PERCENT_LOCATIONS 282
#define PERCENT_LOCATIONS 283 #define PERCENT_NAME_PREFIX 283
#define PERCENT_NAME_PREFIX 284 #define PERCENT_NO_DEFAULT_PREC 284
#define PERCENT_NO_DEFAULT_PREC 285 #define PERCENT_NO_LINES 285
#define PERCENT_NO_LINES 286 #define PERCENT_NONDETERMINISTIC_PARSER 286
#define PERCENT_NONDETERMINISTIC_PARSER 287 #define PERCENT_OUTPUT 287
#define PERCENT_OUTPUT 288 #define PERCENT_PARSE_PARAM 288
#define PERCENT_PARSE_PARAM 289 #define PERCENT_PURE_PARSER 289
#define PERCENT_PURE_PARSER 290 #define PERCENT_REQUIRE 290
#define PERCENT_REQUIRE 291 #define PERCENT_SKELETON 291
#define PERCENT_SKELETON 292 #define PERCENT_START 292
#define PERCENT_START 293 #define PERCENT_TOKEN_TABLE 293
#define PERCENT_TOKEN_TABLE 294 #define PERCENT_VERBOSE 294
#define PERCENT_VERBOSE 295 #define PERCENT_YACC 295
#define PERCENT_YACC 296 #define BRACED_CODE 296
#define TYPE 297 #define CHAR 297
#define EQUAL 298 #define EPILOGUE 298
#define SEMICOLON 299 #define EQUAL 299
#define PIPE 300 #define ID 300
#define ID 301 #define ID_COLON 301
#define ID_COLON 302 #define PERCENT_PERCENT 302
#define PERCENT_PERCENT 303 #define PIPE 303
#define PROLOGUE 304 #define PROLOGUE 304
#define EPILOGUE 305 #define SEMICOLON 305
#define BRACED_CODE 306 #define TYPE 306
#define PERCENT_UNION 307
@@ -156,9 +158,10 @@ typedef union YYSTYPE
char *chars; char *chars;
assoc assoc; assoc assoc;
uniqstr uniqstr; uniqstr uniqstr;
unsigned char character;
} }
/* Line 1529 of yacc.c. */ /* Line 1528 of yacc.c. */
#line 162 "../../src/parse-gram.h" #line 165 "../../src/parse-gram.h"
YYSTYPE; YYSTYPE;
# define yystype YYSTYPE /* obsolescent; will be withdrawn */ # define yystype YYSTYPE /* obsolescent; will be withdrawn */
# define YYSTYPE_IS_DECLARED 1 # define YYSTYPE_IS_DECLARED 1

View File

@@ -99,6 +99,7 @@ static int current_prec = 0;
char *chars; char *chars;
assoc assoc; assoc assoc;
uniqstr uniqstr; uniqstr uniqstr;
unsigned char character;
}; };
/* Define the tokens together with their human representation. */ /* Define the tokens together with their human representation. */
@@ -113,8 +114,6 @@ static int current_prec = 0;
%token PERCENT_DESTRUCTOR "%destructor" %token PERCENT_DESTRUCTOR "%destructor"
%token PERCENT_PRINTER "%printer" %token PERCENT_PRINTER "%printer"
%token PERCENT_UNION "%union {...}"
%token PERCENT_LEFT "%left" %token PERCENT_LEFT "%left"
%token PERCENT_RIGHT "%right" %token PERCENT_RIGHT "%right"
%token PERCENT_NONASSOC "%nonassoc" %token PERCENT_NONASSOC "%nonassoc"
@@ -157,35 +156,37 @@ static int current_prec = 0;
PERCENT_YACC "%yacc" PERCENT_YACC "%yacc"
; ;
%token TYPE "type" %token BRACED_CODE "{...}"
%token CHAR "char"
%token EPILOGUE "epilogue"
%token EQUAL "=" %token EQUAL "="
%token SEMICOLON ";"
%token PIPE "|"
%token ID "identifier" %token ID "identifier"
%token ID_COLON "identifier:" %token ID_COLON "identifier:"
%token PERCENT_PERCENT "%%" %token PERCENT_PERCENT "%%"
%token PIPE "|"
%token PROLOGUE "%{...%}" %token PROLOGUE "%{...%}"
%token EPILOGUE "epilogue" %token SEMICOLON ";"
%token BRACED_CODE "{...}" %token TYPE "type"
%type <chars> STRING string_content %type <character> CHAR
"{...}" %printer { fprintf (stderr, "'%c' (%d)", $$, $$); } CHAR
"%union {...}"
PROLOGUE EPILOGUE %type <chars> STRING string_content "{...}" PROLOGUE EPILOGUE
%printer { fprintf (stderr, "\"%s\"", $$); } %printer { fprintf (stderr, "\"%s\"", $$); } STRING string_content
STRING string_content %printer { fprintf (stderr, "{\n%s\n}", $$); } "{...}" PROLOGUE EPILOGUE
%printer { fprintf (stderr, "{\n%s\n}", $$); }
"{...}" %type <uniqstr> TYPE ID ID_COLON
"%union {...}"
PROLOGUE EPILOGUE
%type <uniqstr> TYPE
%printer { fprintf (stderr, "<%s>", $$); } TYPE %printer { fprintf (stderr, "<%s>", $$); } TYPE
%printer { fprintf (stderr, "%s", $$); } ID
%printer { fprintf (stderr, "%s:", $$); } ID_COLON
%type <integer> INT %type <integer> INT
%printer { fprintf (stderr, "%d", $$); } INT %printer { fprintf (stderr, "%d", $$); } INT
%type <symbol> ID symbol string_as_id
%printer { fprintf (stderr, "%s", $$->tag); } ID symbol string_as_id %type <symbol> id id_colon symbol string_as_id
%type <symbol> ID_COLON %printer { fprintf (stderr, "%s", $$->tag); } id symbol string_as_id
%printer { fprintf (stderr, "%s:", $$->tag); } ID_COLON %printer { fprintf (stderr, "%s:", $$->tag); } id_colon
%type <assoc> precedence_declarator %type <assoc> precedence_declarator
%type <list> symbols.1 %type <list> symbols.1
%% %%
@@ -252,22 +253,6 @@ grammar_declaration:
{ {
grammar_start_symbol_set ($2, @2); grammar_start_symbol_set ($2, @2);
} }
| "%union {...}"
{
char const *body = $1;
if (typed)
{
/* Concatenate the union bodies, turning the first one's
trailing '}' into '\n', and omitting the second one's '{'. */
char *code = muscle_find ("stype");
code[strlen (code) - 1] = '\n';
body++;
}
typed = true;
muscle_code_grow ("stype", body, @1);
}
| "%destructor" "{...}" symbols.1 | "%destructor" "{...}" symbols.1
{ {
symbol_list *list; symbol_list *list;
@@ -294,6 +279,40 @@ grammar_declaration:
} }
; ;
/*----------*
| %union. |
*----------*/
%token PERCENT_UNION "%union";
union_name:
/* Nothing. */ {}
| ID { muscle_code_grow ("union_name", $1, @1); }
;
grammar_declaration:
"%union" union_name "{...}"
{
char const *body = $3;
if (typed)
{
/* Concatenate the union bodies, turning the first one's
trailing '}' into '\n', and omitting the second one's '{'. */
char *code = muscle_find ("stype");
code[strlen (code) - 1] = '\n';
body++;
}
typed = true;
muscle_code_grow ("stype", body, @3);
}
;
symbol_declaration: symbol_declaration:
"%nterm" { current_class = nterm_sym; } symbol_defs.1 "%nterm" { current_class = nterm_sym; } symbol_defs.1
{ {
@@ -352,24 +371,24 @@ symbol_def:
{ {
current_type = $1; current_type = $1;
} }
| ID | id
{ {
symbol_class_set ($1, current_class, @1, true); symbol_class_set ($1, current_class, @1, true);
symbol_type_set ($1, current_type, @1); symbol_type_set ($1, current_type, @1);
} }
| ID INT | id INT
{ {
symbol_class_set ($1, current_class, @1, true); symbol_class_set ($1, current_class, @1, true);
symbol_type_set ($1, current_type, @1); symbol_type_set ($1, current_type, @1);
symbol_user_token_number_set ($1, $2, @2); symbol_user_token_number_set ($1, $2, @2);
} }
| ID string_as_id | id string_as_id
{ {
symbol_class_set ($1, current_class, @1, true); symbol_class_set ($1, current_class, @1, true);
symbol_type_set ($1, current_type, @1); symbol_type_set ($1, current_type, @1);
symbol_make_alias ($1, $2, @$); symbol_make_alias ($1, $2, @$);
} }
| ID INT string_as_id | id INT string_as_id
{ {
symbol_class_set ($1, current_class, @1, true); symbol_class_set ($1, current_class, @1, true);
symbol_type_set ($1, current_type, @1); symbol_type_set ($1, current_type, @1);
@@ -406,7 +425,7 @@ rules_or_grammar_declaration:
; ;
rules: rules:
ID_COLON { current_lhs = $1; current_lhs_location = @1; } rhses.1 id_colon { current_lhs = $1; current_lhs_location = @1; } rhses.1
; ;
rhses.1: rhses.1:
@@ -431,9 +450,32 @@ rhs:
{ grammar_current_rule_merge_set ($3, @3); } { grammar_current_rule_merge_set ($3, @3); }
; ;
/*---------------*
| Identifiers. |
*---------------*/
/* Identifiers are return as uniqstr by the scanner. Depending on
their use, we may need to make them genuine symbols. */
id:
ID { $$ = symbol_get ($1, @1); }
| CHAR { char cp[4] = { '\'', $1, '\'', 0 };
$$ = symbol_get (quotearg_style (escape_quoting_style, cp),
@1);
symbol_class_set ($$, token_sym, @1, false);
symbol_user_token_number_set ($$, $1, @1);
}
;
id_colon:
ID_COLON { $$ = symbol_get ($1, @1); }
;
symbol: symbol:
ID { $$ = $1; } id
| string_as_id { $$ = $1; } | string_as_id
; ;
/* A string used as an ID: quote it. */ /* A string used as an ID: quote it. */

View File

@@ -88,9 +88,6 @@ static void unexpected_newline (boundary, char const *);
/* A identifier was just read in directives/rules. Special state /* A identifier was just read in directives/rules. Special state
to capture the sequence `identifier :'. */ to capture the sequence `identifier :'. */
%x SC_AFTER_IDENTIFIER %x SC_AFTER_IDENTIFIER
/* A keyword that should be followed by some code was read (e.g.
%printer). */
%x SC_PRE_CODE
/* Three types of user code: /* Three types of user code:
- prologue (code between `%{' `%}' in the first section, before %%); - prologue (code between `%{' `%}' in the first section, before %%);
@@ -124,9 +121,6 @@ splice (\\[ \f\t\v]*\n)*
/* Parent context state, when applicable. */ /* Parent context state, when applicable. */
int context_state IF_LINT (= 0); int context_state IF_LINT (= 0);
/* Token type to return, when applicable. */
int token_type IF_LINT (= 0);
/* Location of most recent identifier, when applicable. */ /* Location of most recent identifier, when applicable. */
location id_loc IF_LINT (= empty_location); location id_loc IF_LINT (= empty_location);
@@ -145,7 +139,7 @@ splice (\\[ \f\t\v]*\n)*
| Scanning white space. | | Scanning white space. |
`-----------------------*/ `-----------------------*/
<INITIAL,SC_AFTER_IDENTIFIER,SC_PRE_CODE> <INITIAL,SC_AFTER_IDENTIFIER>
{ {
/* Comments and white space. */ /* Comments and white space. */
"," warn_at (*loc, _("stray `,' treated as white space")); "," warn_at (*loc, _("stray `,' treated as white space"));
@@ -170,46 +164,46 @@ splice (\\[ \f\t\v]*\n)*
`----------------------------*/ `----------------------------*/
<INITIAL> <INITIAL>
{ {
"%binary" return PERCENT_NONASSOC; "%binary" return PERCENT_NONASSOC;
"%debug" return PERCENT_DEBUG; "%debug" return PERCENT_DEBUG;
"%default"[-_]"prec" return PERCENT_DEFAULT_PREC; "%default"[-_]"prec" return PERCENT_DEFAULT_PREC;
"%define" return PERCENT_DEFINE; "%define" return PERCENT_DEFINE;
"%defines" return PERCENT_DEFINES; "%defines" return PERCENT_DEFINES;
"%destructor" /* FIXME: Remove once %union handled differently. */ token_type = BRACED_CODE; return PERCENT_DESTRUCTOR; "%destructor" return PERCENT_DESTRUCTOR;
"%dprec" return PERCENT_DPREC; "%dprec" return PERCENT_DPREC;
"%error"[-_]"verbose" return PERCENT_ERROR_VERBOSE; "%error"[-_]"verbose" return PERCENT_ERROR_VERBOSE;
"%expect" return PERCENT_EXPECT; "%expect" return PERCENT_EXPECT;
"%expect"[-_]"rr" return PERCENT_EXPECT_RR; "%expect"[-_]"rr" return PERCENT_EXPECT_RR;
"%file-prefix" return PERCENT_FILE_PREFIX; "%file-prefix" return PERCENT_FILE_PREFIX;
"%fixed"[-_]"output"[-_]"files" return PERCENT_YACC; "%fixed"[-_]"output"[-_]"files" return PERCENT_YACC;
"%initial-action" /* FIXME: Remove once %union handled differently. */ token_type = BRACED_CODE; return PERCENT_INITIAL_ACTION; "%initial-action" return PERCENT_INITIAL_ACTION;
"%glr-parser" return PERCENT_GLR_PARSER; "%glr-parser" return PERCENT_GLR_PARSER;
"%left" return PERCENT_LEFT; "%left" return PERCENT_LEFT;
"%lex-param" /* FIXME: Remove once %union handled differently. */ token_type = BRACED_CODE; return PERCENT_LEX_PARAM; "%lex-param" return PERCENT_LEX_PARAM;
"%locations" return PERCENT_LOCATIONS; "%locations" return PERCENT_LOCATIONS;
"%merge" return PERCENT_MERGE; "%merge" return PERCENT_MERGE;
"%name"[-_]"prefix" return PERCENT_NAME_PREFIX; "%name"[-_]"prefix" return PERCENT_NAME_PREFIX;
"%no"[-_]"default"[-_]"prec" return PERCENT_NO_DEFAULT_PREC; "%no"[-_]"default"[-_]"prec" return PERCENT_NO_DEFAULT_PREC;
"%no"[-_]"lines" return PERCENT_NO_LINES; "%no"[-_]"lines" return PERCENT_NO_LINES;
"%nonassoc" return PERCENT_NONASSOC; "%nonassoc" return PERCENT_NONASSOC;
"%nondeterministic-parser" return PERCENT_NONDETERMINISTIC_PARSER; "%nondeterministic-parser" return PERCENT_NONDETERMINISTIC_PARSER;
"%nterm" return PERCENT_NTERM; "%nterm" return PERCENT_NTERM;
"%output" return PERCENT_OUTPUT; "%output" return PERCENT_OUTPUT;
"%parse-param" /* FIXME: Remove once %union handled differently. */ token_type = BRACED_CODE; return PERCENT_PARSE_PARAM; "%parse-param" return PERCENT_PARSE_PARAM;
"%prec" return PERCENT_PREC; "%prec" return PERCENT_PREC;
"%printer" /* FIXME: Remove once %union handled differently. */ token_type = BRACED_CODE; return PERCENT_PRINTER; "%printer" return PERCENT_PRINTER;
"%pure"[-_]"parser" return PERCENT_PURE_PARSER; "%pure"[-_]"parser" return PERCENT_PURE_PARSER;
"%require" return PERCENT_REQUIRE; "%require" return PERCENT_REQUIRE;
"%right" return PERCENT_RIGHT; "%right" return PERCENT_RIGHT;
"%skeleton" return PERCENT_SKELETON; "%skeleton" return PERCENT_SKELETON;
"%start" return PERCENT_START; "%start" return PERCENT_START;
"%term" return PERCENT_TOKEN; "%term" return PERCENT_TOKEN;
"%token" return PERCENT_TOKEN; "%token" return PERCENT_TOKEN;
"%token"[-_]"table" return PERCENT_TOKEN_TABLE; "%token"[-_]"table" return PERCENT_TOKEN_TABLE;
"%type" return PERCENT_TYPE; "%type" return PERCENT_TYPE;
"%union" token_type = PERCENT_UNION; BEGIN SC_PRE_CODE; "%union" return PERCENT_UNION;
"%verbose" return PERCENT_VERBOSE; "%verbose" return PERCENT_VERBOSE;
"%yacc" return PERCENT_YACC; "%yacc" return PERCENT_YACC;
{directive} { {directive} {
complain_at (*loc, _("invalid directive: %s"), quote (yytext)); complain_at (*loc, _("invalid directive: %s"), quote (yytext));
@@ -220,7 +214,7 @@ splice (\\[ \f\t\v]*\n)*
";" return SEMICOLON; ";" return SEMICOLON;
{id} { {id} {
val->symbol = symbol_get (yytext, *loc); val->uniqstr = uniqstr_new (yytext);
id_loc = *loc; id_loc = *loc;
BEGIN SC_AFTER_IDENTIFIER; BEGIN SC_AFTER_IDENTIFIER;
} }
@@ -248,7 +242,6 @@ splice (\\[ \f\t\v]*\n)*
if (current_rule && current_rule->action) if (current_rule && current_rule->action)
grammar_midrule_action (); grammar_midrule_action ();
STRING_GROW; STRING_GROW;
token_type = BRACED_CODE;
braces_level = 0; braces_level = 0;
code_start = loc->start; code_start = loc->start;
BEGIN SC_BRACED_CODE; BEGIN SC_BRACED_CODE;
@@ -372,15 +365,10 @@ splice (\\[ \f\t\v]*\n)*
STRING_GROW; STRING_GROW;
STRING_FINISH; STRING_FINISH;
loc->start = token_start; loc->start = token_start;
val->symbol = symbol_get (quotearg_style (escape_quoting_style, val->character = last_string[1];
last_string),
*loc);
symbol_class_set (val->symbol, token_sym, *loc, false);
last_string_1 = last_string[1];
symbol_user_token_number_set (val->symbol, last_string_1, *loc);
STRING_FREE; STRING_FREE;
BEGIN INITIAL; BEGIN INITIAL;
return ID; return CHAR;
} }
\n unexpected_newline (token_start, "'"); BEGIN INITIAL; \n unexpected_newline (token_start, "'"); BEGIN INITIAL;
<<EOF>> unexpected_eof (token_start, "'"); BEGIN INITIAL; <<EOF>> unexpected_eof (token_start, "'"); BEGIN INITIAL;
@@ -501,45 +489,11 @@ splice (\\[ \f\t\v]*\n)*
} }
/*---------------------------------------------------------------.
| Scanning after %union etc., possibly followed by white space. |
| For %union only, allow arbitrary C code to appear before the |
| following brace, as an extension to POSIX. |
`---------------------------------------------------------------*/
<SC_PRE_CODE> /*-----------------------------------------------------------.
{ | Scanning some code in braces (actions). The initial "{" is |
. { | already eaten. |
bool valid = yytext[0] == '{' || token_type == PERCENT_UNION; `-----------------------------------------------------------*/
scanner_cursor.column -= mbsnwidth (yytext, yyleng, 0);
yyless (0);
if (valid)
{
braces_level = -1;
code_start = loc->start;
BEGIN SC_BRACED_CODE;
}
else
{
complain_at (*loc, _("missing `{' in %s"),
token_name (token_type));
obstack_sgrow (&obstack_for_string, "{}");
STRING_FINISH;
val->chars = last_string;
BEGIN INITIAL;
return token_type;
}
}
<<EOF>> unexpected_eof (scanner_cursor, "{}"); BEGIN INITIAL;
}
/*---------------------------------------------------------------.
| Scanning some code in braces (%union and actions). The initial |
| "{" is already eaten. |
`---------------------------------------------------------------*/
<SC_BRACED_CODE> <SC_BRACED_CODE>
{ {
@@ -556,7 +510,7 @@ splice (\\[ \f\t\v]*\n)*
val->chars = last_string; val->chars = last_string;
gram_last_braced_code_loc = *loc; gram_last_braced_code_loc = *loc;
BEGIN INITIAL; BEGIN INITIAL;
return token_type; return BRACED_CODE;
} }
} }