From: Akim Demaille Date: Thu, 4 Apr 2013 13:32:49 +0000 (+0200) Subject: grammar: split %union to group together related aspects X-Git-Tag: v2.7.90~58 X-Git-Url: https://git.saurik.com/bison.git/commitdiff_plain/a17c70f876111f81e2968acfef936b7127660acd?hp=c56d0037d290a2ec1e6a05fda0be753fdeca655c grammar: split %union to group together related aspects * src/parse-gram.y (INT): Fuse the %type and %token declaration. Move its %union right before its introduction. (%union): Split in several %unions, right before their use. --- diff --git a/src/parse-gram.y b/src/parse-gram.y index e4d36cc7..50b90cf0 100644 --- a/src/parse-gram.y +++ b/src/parse-gram.y @@ -101,23 +101,9 @@ static char const *char_name (char); boundary_set (&@$.end, current_file, 1, 1); } -%union -{ - assoc assoc; - char *code; - char const *chars; - int integer; - named_ref *named_ref; - symbol *symbol; - symbol_list *list; - uniqstr uniqstr; - unsigned char character; -}; - /* Define the tokens together with their human representation. */ %token GRAM_EOF 0 "end of file" %token STRING "string" -%token INT "integer" %token PERCENT_TOKEN "%token" %token PERCENT_NTERM "%nterm" @@ -182,11 +168,17 @@ static char const *char_name (char); %token TAG_ANY "<*>" %token TAG_NONE "<>" +%union {unsigned char character;} %type CHAR %printer { fputs (char_name ($$), yyo); } CHAR /* braceless is not to be used for rule or symbol actions, as it calls code_props_plain_init. */ +%union +{ + char *code; + char const *chars; +}; %type STRING "%{...%}" EPILOGUE braceless content.opt %type "{...}" "%?{...}" %printer { fputs (quotearg_style (c_quoting_style, $$), yyo); } @@ -194,6 +186,7 @@ static char const *char_name (char); %printer { fprintf (yyo, "{\n%s\n}", $$); } braceless content.opt "{...}" "%{...%}" EPILOGUE +%union {uniqstr uniqstr;} %type BRACKETED_ID ID ID_COLON PERCENT_FLAG TAG tag variable %printer { fputs ($$, yyo); } %printer { fprintf (yyo, "[%s]", $$); } BRACKETED_ID @@ -201,15 +194,22 @@ static char const *char_name (char); %printer { fprintf (yyo, "%%%s", $$); } PERCENT_FLAG %printer { fprintf (yyo, "<%s>", $$); } TAG tag -%type INT +%union {int integer;}; +%token INT "integer" %printer { fprintf (yyo, "%d", $$); } +%union {symbol *symbol;} %type id id_colon string_as_id symbol symbol.prec %printer { fprintf (yyo, "%s", $$->tag); } %printer { fprintf (yyo, "%s:", $$->tag); } id_colon +%union {assoc assoc;}; %type precedence_declarator + +%union {symbol_list *list;} %type symbols.1 symbols.prec generic_symlist generic_symlist_item + +%union {named_ref *named_ref;} %type named_ref.opt /*---------.