mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-14 06:43:03 +00:00
dogfooding: use api.value.type union
* src/parse-gram.y (api.value.type): Set to union. Replace occurrences of %union with explicit %types. * src/scan-gram.l: Adjust yylval's field names. (RETURN_VALUE): No longer needs the Field argument. Use it more.
This commit is contained in:
@@ -97,6 +97,7 @@
|
||||
|
||||
%define api.prefix {gram_}
|
||||
%define api.pure full
|
||||
%define api.value.type union
|
||||
%define locations
|
||||
%define parse.error verbose
|
||||
%define parse.lac full
|
||||
@@ -180,16 +181,13 @@
|
||||
%token TAG_ANY "<*>"
|
||||
%token TAG_NONE "<>"
|
||||
|
||||
%union {unsigned char character;}
|
||||
%type <character> CHAR
|
||||
%printer { fputs (char_name ($$), yyo); } CHAR
|
||||
%type <unsigned char> CHAR
|
||||
%printer { fputs (char_name ($$), yyo); } <unsigned char>
|
||||
|
||||
%union {char *code;};
|
||||
%type <code> "{...}" "%?{...}" "%{...%}" EPILOGUE STRING
|
||||
%type <char*> "{...}" "%?{...}" "%{...%}" EPILOGUE STRING
|
||||
%printer { fputs (quotearg_style (c_quoting_style, $$), yyo); } STRING
|
||||
%printer { fprintf (yyo, "{\n%s\n}", $$); } <code>
|
||||
%printer { fprintf (yyo, "{\n%s\n}", $$); } <char*>
|
||||
|
||||
%union {uniqstr uniqstr;}
|
||||
%type <uniqstr> BRACKETED_ID ID ID_COLON PERCENT_FLAG TAG tag variable
|
||||
%printer { fputs ($$, yyo); } <uniqstr>
|
||||
%printer { fprintf (yyo, "[%s]", $$); } BRACKETED_ID
|
||||
@@ -197,23 +195,18 @@
|
||||
%printer { fprintf (yyo, "%%%s", $$); } PERCENT_FLAG
|
||||
%printer { fprintf (yyo, "<%s>", $$); } TAG tag
|
||||
|
||||
%union {int integer;};
|
||||
%token <integer> INT "integer"
|
||||
%printer { fprintf (yyo, "%d", $$); } <integer>
|
||||
%token <int> INT "integer"
|
||||
%printer { fprintf (yyo, "%d", $$); } <int>
|
||||
|
||||
%union {symbol *symbol;}
|
||||
%type <symbol> id id_colon string_as_id symbol symbol.prec
|
||||
%printer { fprintf (yyo, "%s", $$->tag); } <symbol>
|
||||
%type <symbol*> id id_colon string_as_id symbol symbol.prec
|
||||
%printer { fprintf (yyo, "%s", $$->tag); } <symbol*>
|
||||
%printer { fprintf (yyo, "%s:", $$->tag); } id_colon
|
||||
|
||||
%union {assoc assoc;};
|
||||
%type <assoc> precedence_declarator
|
||||
|
||||
%union {symbol_list *list;}
|
||||
%type <list> symbols.1 symbols.prec generic_symlist generic_symlist_item
|
||||
%type <symbol_list*> symbols.1 symbols.prec generic_symlist generic_symlist_item
|
||||
|
||||
%union {named_ref *named_ref;}
|
||||
%type <named_ref> named_ref.opt
|
||||
%type <named_ref*> named_ref.opt
|
||||
|
||||
/*---------.
|
||||
| %param. |
|
||||
@@ -239,8 +232,7 @@
|
||||
static void add_param (param_type type, char *decl, location loc);
|
||||
static param_type current_param = param_none;
|
||||
};
|
||||
%union {param_type param;}
|
||||
%token <param> PERCENT_PARAM "%param";
|
||||
%token <param_type> PERCENT_PARAM "%param";
|
||||
%printer
|
||||
{
|
||||
switch ($$)
|
||||
@@ -253,7 +245,7 @@
|
||||
#undef CASE
|
||||
case param_none: aver (false); break;
|
||||
}
|
||||
} <param>;
|
||||
} <param_type>;
|
||||
|
||||
|
||||
/*==========\
|
||||
@@ -405,9 +397,8 @@ grammar_declaration:
|
||||
}
|
||||
;
|
||||
|
||||
%type <code_type> code_props_type;
|
||||
%union {code_props_type code_type;};
|
||||
%printer { fprintf (yyo, "%s", code_props_type_string ($$)); } <code_type>;
|
||||
%type <code_props_type> code_props_type;
|
||||
%printer { fprintf (yyo, "%s", code_props_type_string ($$)); } <code_props_type>;
|
||||
code_props_type:
|
||||
"%destructor" { $$ = destructor; }
|
||||
| "%printer" { $$ = printer; }
|
||||
@@ -642,16 +633,15 @@ variable:
|
||||
;
|
||||
|
||||
/* Some content or empty by default. */
|
||||
%code requires {#include "muscle-tab.h"};
|
||||
%union
|
||||
{
|
||||
struct
|
||||
%code requires {
|
||||
#include "muscle-tab.h"
|
||||
typedef struct
|
||||
{
|
||||
char const *chars;
|
||||
muscle_kind kind;
|
||||
} value;
|
||||
} value_type;
|
||||
};
|
||||
%type <value> value;
|
||||
%type <value_type> value;
|
||||
%printer
|
||||
{
|
||||
switch ($$.kind)
|
||||
@@ -660,7 +650,7 @@ variable:
|
||||
case muscle_keyword: fprintf (yyo, "%s", $$.chars); break;
|
||||
case muscle_string: fprintf (yyo, "\"%s\"", $$.chars); break;
|
||||
}
|
||||
} <value>;
|
||||
} <value_type>;
|
||||
|
||||
value:
|
||||
%empty { $$.kind = muscle_keyword; $$.chars = ""; }
|
||||
|
||||
Reference in New Issue
Block a user