mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-16 15:53:03 +00:00
* src/symlist.h, src/symlist.c (symbol_list_length): New.
* src/scan-gram.l (handle_dollar, handle_at): Compute the rule_length only when needed. * src/output.c (actions_output, token_definitions_output): Output the full M4 block. * src/symtab.c: Don't access directly to the symbol tag, use symbol_tag_get. * src/parse-gram.y: Use symbol_list_free.
This commit is contained in:
@@ -524,15 +524,6 @@ handle_dollar (char *cp, location_t location)
|
||||
{
|
||||
const char *type_name = NULL;
|
||||
|
||||
/* RULE_LENGTH is the number of values in the current rule so far,
|
||||
which says where to find `$0' with respect to the top of the
|
||||
stack. It is not the same as the rule->length in the case of mid
|
||||
rule actions. */
|
||||
int rule_length = 0;
|
||||
symbol_list_t *rhs;
|
||||
for (rhs = current_rule->next; rhs; rhs = rhs->next)
|
||||
++rule_length;
|
||||
|
||||
++cp;
|
||||
|
||||
/* Get the type name if explicit. */
|
||||
@@ -559,6 +550,11 @@ handle_dollar (char *cp, location_t location)
|
||||
}
|
||||
else if (isdigit (*cp) || *cp == '-')
|
||||
{
|
||||
/* RULE_LENGTH is the number of values in the current rule so
|
||||
far, which says where to find `$0' with respect to the top of
|
||||
the stack. It is not the same as the rule->length in the
|
||||
case of mid rule actions. */
|
||||
int rule_length = symbol_list_length (current_rule->next);
|
||||
int n = strtol (cp, &cp, 10);
|
||||
|
||||
if (n > rule_length)
|
||||
@@ -594,15 +590,6 @@ handle_dollar (char *cp, location_t location)
|
||||
static void
|
||||
handle_at (char *cp)
|
||||
{
|
||||
/* RULE_LENGTH is the number of values in the current rule so far,
|
||||
which says where to find `$0' with respect to the top of the
|
||||
stack. It is not the same as the rule->length in the case of mid
|
||||
rule actions. */
|
||||
int rule_length = 0;
|
||||
symbol_list_t *rhs;
|
||||
for (rhs = current_rule->next; rhs; rhs = rhs->next)
|
||||
++rule_length;
|
||||
|
||||
locations_flag = 1;
|
||||
++cp;
|
||||
|
||||
@@ -612,7 +599,13 @@ handle_at (char *cp)
|
||||
}
|
||||
else if (isdigit (*cp) || *cp == '-')
|
||||
{
|
||||
/* RULE_LENGTH is the number of values in the current rule so
|
||||
far, which says where to find `$0' with respect to the top of
|
||||
the stack. It is not the same as the rule->length in the
|
||||
case of mid rule actions. */
|
||||
int rule_length = symbol_list_length (current_rule->next);
|
||||
int n = strtol (cp, &cp, 10);
|
||||
|
||||
if (n > rule_length)
|
||||
complain (_("invalid value: %s%d"), "@", n);
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user