mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-16 15:53:03 +00:00
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:
@@ -466,8 +466,8 @@ symbol.prec:
|
||||
| symbol INT
|
||||
{
|
||||
$$ = $1;
|
||||
symbol_user_token_number_set ($1, $2, @2);
|
||||
symbol_class_set ($1, token_sym, @1, false);
|
||||
symbol_user_token_number_set ($1, $2, @2);
|
||||
}
|
||||
;
|
||||
|
||||
@@ -507,23 +507,9 @@ symbol_def:
|
||||
symbol_class_set ($id, current_class, @id, true);
|
||||
symbol_type_set ($id, current_type, @id);
|
||||
if (0 <= $num)
|
||||
{
|
||||
if (current_class != token_sym)
|
||||
gram_error (&@num,
|
||||
_("non-terminals cannot be given an explicit number"));
|
||||
else
|
||||
symbol_user_token_number_set ($id, $num, @num);
|
||||
}
|
||||
symbol_user_token_number_set ($id, $num, @num);
|
||||
if ($alias)
|
||||
{
|
||||
if (current_class != token_sym)
|
||||
gram_error (&@alias,
|
||||
_("non-terminals cannot be given a string alias"));
|
||||
else
|
||||
symbol_make_alias ($id, $alias, @alias);
|
||||
}
|
||||
if (current_class != token_sym && (0 <= $num || $alias))
|
||||
YYERROR;
|
||||
symbol_make_alias ($id, $alias, @alias);
|
||||
}
|
||||
;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user