mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-12 13:53:03 +00:00
* NEWS: Instead of %union, you can define and use your own union type
YYSTYPE if your grammar contains at least one <type> tag. Your YYSTYPE need not be a macro; it can be a typedef. * doc/bison.texinfo (Value Type, Multiple Types, Location Type): (Union Decl, Decl Summary): Document this. * data/glr.c (YYSTYPE): Implement this. * data/glr.cc (YYSTYPE): Likewise. * data/lalr1.cc (YYSTYPE): Likewise. * data/yacc.c (YYSTYPE): Likewise. * src/output.c (prepare): Output tag_seen_flag. * src/parse-gram.y (declaration, grammar_declaration): Use 'union_seen' rather than 'typed' to determine whether %union has been seen, since grammars can now be typed without %union. (symbol_declaration, type.opt, symbol_def): Keep track of whether a tag has been seen. * src/reader.c (union_seen, tag_seen): New vars. (typed): remove. * src/reader.h (union_seen, tag_seen, typed): Likewise. * src/scan-code.l (untyped_var_seen): New variable. (handle_action_dollar): Adjust to above changes. (handle_action_dollar, handle_action_at): Improve overflow checking for outlandish numbers. * tests/input.at (AT_CHECK_UNUSED_VALUES): Redo test to avoid new diagnostics generated by above changes. * tests/regression.at (YYSTYPE typedef): Add test to check for type tags without %union.
This commit is contained in:
@@ -57,7 +57,7 @@ static char const *char_name (char);
|
||||
static void add_param (char const *, char *, location);
|
||||
|
||||
static symbol_class current_class = unknown_sym;
|
||||
static uniqstr current_type = 0;
|
||||
static uniqstr current_type = NULL;
|
||||
static symbol *current_lhs;
|
||||
static location current_lhs_location;
|
||||
static int current_prec = 0;
|
||||
@@ -209,7 +209,7 @@ declaration:
|
||||
grammar_declaration
|
||||
| PROLOGUE
|
||||
{
|
||||
prologue_augment (translate_code ($1, @1), @1, typed);
|
||||
prologue_augment (translate_code ($1, @1), @1, union_seen);
|
||||
}
|
||||
| "%after-header" "{...}"
|
||||
{
|
||||
@@ -322,7 +322,7 @@ grammar_declaration:
|
||||
{
|
||||
char const *body = $3;
|
||||
|
||||
if (typed)
|
||||
if (union_seen)
|
||||
{
|
||||
/* Concatenate the union bodies, turning the first one's
|
||||
trailing '}' into '\n', and omitting the second one's '{'. */
|
||||
@@ -331,7 +331,7 @@ grammar_declaration:
|
||||
body++;
|
||||
}
|
||||
|
||||
typed = true;
|
||||
union_seen = true;
|
||||
muscle_code_grow ("stype", body, @3);
|
||||
}
|
||||
;
|
||||
@@ -352,6 +352,7 @@ symbol_declaration:
|
||||
}
|
||||
| "%type" TYPE symbols.1
|
||||
{
|
||||
tag_seen = true;
|
||||
symbol_list *list;
|
||||
for (list = $3; list; list = list->next)
|
||||
symbol_type_set (list->sym, $2, @2);
|
||||
@@ -382,7 +383,7 @@ precedence_declarator:
|
||||
|
||||
type.opt:
|
||||
/* Nothing. */ { current_type = NULL; }
|
||||
| TYPE { current_type = $1; }
|
||||
| TYPE { current_type = $1; tag_seen = true; }
|
||||
;
|
||||
|
||||
/* One or more nonterminals to be %typed. */
|
||||
@@ -396,6 +397,7 @@ symbol_def:
|
||||
TYPE
|
||||
{
|
||||
current_type = $1;
|
||||
tag_seen = true;
|
||||
}
|
||||
| id
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user