parser: move checks inside the called functions

Revamping the handling of the symbols is the grammar is much more
delicate than I anticipated.  Let's first move things around for
clarity.

* src/symtab.c (symbol_make_alias): Don't accept to alias
non-terminals.
(symbol_user_token_number_set): Don't accept user token numbers
for non-terminals.
Don't do anything in case of redefinition, instead of trying to
update.  The flow is eaier to follow this way.
This commit is contained in:
Akim Demaille
2018-11-30 06:11:00 +01:00
parent e1a843cc69
commit 157f12c483
3 changed files with 32 additions and 31 deletions

View File

@@ -137,6 +137,10 @@ struct sym_content
location prec_location;
int prec;
assoc assoc;
/** The user specified token number.
E.g., %token FOO 42.*/
int user_token_number;
symbol_class class;
@@ -212,7 +216,10 @@ code_props *symbol_code_props_get (symbol *sym, code_props_type kind);
Do nothing if invoked with \c undef_assoc as \c assoc. */
void symbol_precedence_set (symbol *sym, int prec, assoc a, location loc);
/** Set the \c class associated with \c sym. */
/** Set the \c class associated with \c sym.
Whether \c declaring means whether this class definition comes
from %nterm or %token. */
void symbol_class_set (symbol *sym, symbol_class class, location loc,
bool declaring);