mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-09 04:13:03 +00:00
* src/symtab.c, src/symtab.c (symbol_type_set)
(symbol_precedence_set): New. * src/reader.c (parse_type_decl, parse_assoc_decl): Use them. (value_components_used): Remove, unused.
This commit is contained in:
@@ -1,3 +1,10 @@
|
||||
2002-06-10 Akim Demaille <akim@epita.fr>
|
||||
|
||||
* src/symtab.c, src/symtab.c (symbol_type_set)
|
||||
(symbol_precedence_set): New.
|
||||
* src/reader.c (parse_type_decl, parse_assoc_decl): Use them.
|
||||
(value_components_used): Remove, unused.
|
||||
|
||||
2002-06-09 Akim Demaille <akim@epita.fr>
|
||||
|
||||
Move symbols handling code out of the reader.
|
||||
|
||||
5
TODO
5
TODO
@@ -3,6 +3,11 @@
|
||||
* URGENT: Documenting C++ output
|
||||
Write a first documentation for C++ output.
|
||||
|
||||
* value_components_used
|
||||
Was defined but not used: where was it coming from? It can't be to
|
||||
check if %union is used, since the user is free to $<foo>n on her
|
||||
union, doesn't she?
|
||||
|
||||
* yyerror, yyprint interface
|
||||
It should be improved, in particular when using Bison features such as
|
||||
locations, and YYPARSE_PARAMS. For the time being, it is recommended
|
||||
|
||||
26
src/reader.c
26
src/reader.c
@@ -52,10 +52,6 @@ int lineno;
|
||||
static symbol_list *grammar = NULL;
|
||||
static int start_flag = 0;
|
||||
|
||||
/* Nonzero if components of semantic values are used, implying
|
||||
they must be unions. */
|
||||
static int value_components_used;
|
||||
|
||||
/* Nonzero if %union has been seen. */
|
||||
static int typed = 0;
|
||||
|
||||
@@ -378,7 +374,6 @@ copy_dollar (FILE *fin, struct obstack *oout,
|
||||
{
|
||||
read_type_name (fin);
|
||||
type_name = token_buffer;
|
||||
value_components_used = 1;
|
||||
c = getc (fin);
|
||||
}
|
||||
|
||||
@@ -525,7 +520,6 @@ parse_token_decl (symbol_class what_is, symbol_class what_is_not)
|
||||
if (token == tok_typename)
|
||||
{
|
||||
typename = xstrdup (token_buffer);
|
||||
value_components_used = 1;
|
||||
symbol = NULL;
|
||||
}
|
||||
else if (token == tok_identifier && *symval->tag == '\"' && symbol)
|
||||
@@ -630,17 +624,12 @@ parse_type_decl (void)
|
||||
|
||||
switch (t)
|
||||
{
|
||||
|
||||
case tok_comma:
|
||||
case tok_semicolon:
|
||||
break;
|
||||
|
||||
case tok_identifier:
|
||||
if (symval->type_name == NULL)
|
||||
symval->type_name = name;
|
||||
else if (strcmp (name, symval->type_name) != 0)
|
||||
complain (_("type redeclaration for %s"), symval->tag);
|
||||
|
||||
symbol_type_set (symval, name);
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -689,10 +678,6 @@ parse_assoc_decl (associativity assoc)
|
||||
break;
|
||||
|
||||
case tok_identifier:
|
||||
if (symval->prec != 0)
|
||||
complain (_("redefining precedence of %s"), symval->tag);
|
||||
symval->prec = lastprec;
|
||||
symval->assoc = assoc;
|
||||
if (symval->class == nterm_sym)
|
||||
complain (_("symbol %s redefined"), symval->tag);
|
||||
if (symval->number == NUMBER_UNDEFINED)
|
||||
@@ -700,13 +685,9 @@ parse_assoc_decl (associativity assoc)
|
||||
symval->number = ntokens++;
|
||||
symval->class = token_sym;
|
||||
}
|
||||
symbol_precedence_set (symval, lastprec, assoc);
|
||||
if (name)
|
||||
{ /* record the type, if one is specified */
|
||||
if (symval->type_name == NULL)
|
||||
symval->type_name = name;
|
||||
else if (strcmp (name, symval->type_name) != 0)
|
||||
complain (_("type redeclaration for %s"), symval->tag);
|
||||
}
|
||||
symbol_type_set (symval, name);
|
||||
break;
|
||||
|
||||
case tok_number:
|
||||
@@ -851,7 +832,6 @@ parse_thong_decl (void)
|
||||
if (token == tok_typename)
|
||||
{
|
||||
typename = xstrdup (token_buffer);
|
||||
value_components_used = 1;
|
||||
token = lex (); /* fetch first token */
|
||||
}
|
||||
|
||||
|
||||
28
src/symtab.c
28
src/symtab.c
@@ -59,6 +59,34 @@ symbol_new (const char *tag)
|
||||
}
|
||||
|
||||
|
||||
/*-----------------------------------------.
|
||||
| Set the TYPE_NAME associated to SYMBOL. |
|
||||
`-----------------------------------------*/
|
||||
|
||||
void
|
||||
symbol_type_set (symbol_t *symbol, char *type_name)
|
||||
{
|
||||
if (symbol->type_name)
|
||||
complain (_("type redeclaration for %s"), symbol->tag);
|
||||
symbol->type_name = type_name;
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------.
|
||||
| Set the PRECEDENCE associated to SYMBOL. |
|
||||
`------------------------------------------*/
|
||||
|
||||
void
|
||||
symbol_precedence_set (symbol_t *symbol,
|
||||
int prec, associativity assoc)
|
||||
{
|
||||
if (symbol->prec != 0)
|
||||
complain (_("redefining precedence of %s"), symbol->tag);
|
||||
symbol->prec = prec;
|
||||
symbol->assoc = assoc;
|
||||
}
|
||||
|
||||
|
||||
/*------------.
|
||||
| Free THIS. |
|
||||
`------------*/
|
||||
|
||||
@@ -89,6 +89,13 @@ symbol_t *getsym PARAMS ((const char *key));
|
||||
void symbol_make_alias PARAMS ((symbol_t *symbol, symbol_t *symval,
|
||||
char *typename));
|
||||
|
||||
/* Set the TYPE_NAME associated to SYMBOL. */
|
||||
void symbol_type_set PARAMS ((symbol_t *symbol, char *type_name));
|
||||
|
||||
/* Set the PRECEDENCE associated to SYMBOL. */
|
||||
void symbol_precedence_set PARAMS ((symbol_t *symbol,
|
||||
int prec, associativity assoc));
|
||||
|
||||
/* Distinguished symbols. AXIOM is the real start symbol, that used
|
||||
by the automaton. STARTSYMBOL is the one specified by the user.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user