(symbol_precedence_set): New.
* src/reader.c (parse_type_decl, parse_assoc_decl): Use them.
(value_components_used): Remove, unused.
+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.
* 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
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;
{
read_type_name (fin);
type_name = token_buffer;
- value_components_used = 1;
c = getc (fin);
}
if (token == tok_typename)
{
typename = xstrdup (token_buffer);
- value_components_used = 1;
symbol = NULL;
}
else if (token == tok_identifier && *symval->tag == '\"' && symbol)
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:
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)
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:
if (token == tok_typename)
{
typename = xstrdup (token_buffer);
- value_components_used = 1;
token = lex (); /* fetch first token */
}
}
+/*-----------------------------------------.
+| 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. |
`------------*/
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.
*/