mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-22 02:33:03 +00:00
symbols: set tag_seen when assigning a type to symbols
* src/reader.h, src/reader.c (tag_seen): Move to... * src/symtab.h, src/symtab.c: here. (symbol_type_set): Set it to true. * src/parse-gram.y: Don't.
This commit is contained in:
@@ -417,7 +417,6 @@ symbol_declaration:
|
|||||||
}
|
}
|
||||||
| "%type" TAG symbols.1
|
| "%type" TAG symbols.1
|
||||||
{
|
{
|
||||||
tag_seen = true;
|
|
||||||
for (symbol_list *list = $3; list; list = list->next)
|
for (symbol_list *list = $3; list; list = list->next)
|
||||||
symbol_type_set (list->content.sym, $2, @2);
|
symbol_type_set (list->content.sym, $2, @2);
|
||||||
symbol_list_free ($3);
|
symbol_list_free ($3);
|
||||||
@@ -446,7 +445,7 @@ precedence_declarator:
|
|||||||
|
|
||||||
tag.opt:
|
tag.opt:
|
||||||
%empty { $$ = NULL; }
|
%empty { $$ = NULL; }
|
||||||
| TAG { $$ = $1; tag_seen = true; }
|
| TAG { $$ = $1; }
|
||||||
;
|
;
|
||||||
|
|
||||||
/* Just like symbols.1 but accept INT for the sake of POSIX. */
|
/* Just like symbols.1 but accept INT for the sake of POSIX. */
|
||||||
@@ -496,7 +495,6 @@ symbol_def:
|
|||||||
TAG
|
TAG
|
||||||
{
|
{
|
||||||
current_type = $1;
|
current_type = $1;
|
||||||
tag_seen = true;
|
|
||||||
}
|
}
|
||||||
| id int.opt[num] string_as_id.opt[alias]
|
| id int.opt[num] string_as_id.opt[alias]
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -45,9 +45,6 @@ merger_list *merge_functions;
|
|||||||
/* Was %union seen? */
|
/* Was %union seen? */
|
||||||
bool union_seen = false;
|
bool union_seen = false;
|
||||||
|
|
||||||
/* Was a tag seen? */
|
|
||||||
bool tag_seen = false;
|
|
||||||
|
|
||||||
/* Should rules have a default precedence? */
|
/* Should rules have a default precedence? */
|
||||||
bool default_prec = true;
|
bool default_prec = true;
|
||||||
|
|
||||||
|
|||||||
@@ -69,9 +69,6 @@ extern merger_list *merge_functions;
|
|||||||
/* Was %union seen? */
|
/* Was %union seen? */
|
||||||
extern bool union_seen;
|
extern bool union_seen;
|
||||||
|
|
||||||
/* Was a tag seen? */
|
|
||||||
extern bool tag_seen;
|
|
||||||
|
|
||||||
/* Should rules have a default precedence? */
|
/* Should rules have a default precedence? */
|
||||||
extern bool default_prec;
|
extern bool default_prec;
|
||||||
|
|
||||||
|
|||||||
14
src/symtab.c
14
src/symtab.c
@@ -46,17 +46,14 @@ symbol *accept = NULL;
|
|||||||
symbol *startsymbol = NULL;
|
symbol *startsymbol = NULL;
|
||||||
location startsymbol_location;
|
location startsymbol_location;
|
||||||
|
|
||||||
/*---------------------------.
|
/* Precedence relation graph. */
|
||||||
| Precedence relation graph. |
|
|
||||||
`---------------------------*/
|
|
||||||
|
|
||||||
static symgraph **prec_nodes;
|
static symgraph **prec_nodes;
|
||||||
|
|
||||||
/*-----------------------------------.
|
/* Store which associativity is used. */
|
||||||
| Store which associativity is used. |
|
static bool *used_assoc = NULL;
|
||||||
`-----------------------------------*/
|
|
||||||
|
bool tag_seen = false;
|
||||||
|
|
||||||
bool *used_assoc = NULL;
|
|
||||||
|
|
||||||
/*--------------------------.
|
/*--------------------------.
|
||||||
| Create a new sym_content. |
|
| Create a new sym_content. |
|
||||||
@@ -334,6 +331,7 @@ symbol_type_set (symbol *sym, uniqstr type_name, location loc)
|
|||||||
{
|
{
|
||||||
if (type_name)
|
if (type_name)
|
||||||
{
|
{
|
||||||
|
tag_seen = true;
|
||||||
if (sym->content->type_name)
|
if (sym->content->type_name)
|
||||||
complain_symbol_redeclared (sym, "%type",
|
complain_symbol_redeclared (sym, "%type",
|
||||||
sym->content->type_location, loc);
|
sym->content->type_location, loc);
|
||||||
|
|||||||
@@ -248,6 +248,8 @@ extern symbol *startsymbol;
|
|||||||
/** The location of the \c \%start declaration. */
|
/** The location of the \c \%start declaration. */
|
||||||
extern location startsymbol_location;
|
extern location startsymbol_location;
|
||||||
|
|
||||||
|
/** Whether a symbol declared with a type tag. */
|
||||||
|
extern bool tag_seen;
|
||||||
|
|
||||||
|
|
||||||
/*-------------------.
|
/*-------------------.
|
||||||
|
|||||||
Reference in New Issue
Block a user