mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-14 14:53:03 +00:00
multistart: allow tokens as start symbols
After all, why not? * src/reader.c (switching_token): Use symbol_id_get. (check_start_symbols): Require that the start symbol is a token only if it's the only one. * examples/c/lexcalc/parse.y: Let NUM be a start symbol.
This commit is contained in:
11
src/symtab.c
11
src/symtab.c
@@ -305,9 +305,14 @@ is_identifier (uniqstr s)
|
||||
uniqstr
|
||||
symbol_id_get (symbol const *sym)
|
||||
{
|
||||
if (sym->alias)
|
||||
sym = sym->alias;
|
||||
return is_identifier (sym->tag) ? sym->tag : 0;
|
||||
// There's one weird case: YYerror is the alias, and error is the
|
||||
// base symbol. Return YYerror in that case.
|
||||
if (sym->alias && is_identifier (sym->alias->tag))
|
||||
return sym->alias->tag;
|
||||
else if (is_identifier (sym->tag))
|
||||
return sym->tag;
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user