grammar_symbol_append (symbol *sym, location loc)
{
symbol_list *p = symbol_list_sym_new (sym, loc);
grammar_symbol_append (symbol *sym, location loc)
{
symbol_list *p = symbol_list_sym_new (sym, loc);
+static void
+assign_named_ref (symbol_list *p, named_ref *name)
+{
+ symbol *sym = p->content.sym;
+
+ if (name->id == sym->tag)
+ {
+ warn_at (name->loc,
+ _("duplicated symbol name for %s ignored"),
+ quote (sym->tag));
+ named_ref_free (name);
+ }
+ else
+ p->named_ref = name;
+}
+
+
/* The rule currently being defined, and the previous rule.
CURRENT_RULE points to the first LHS of the current rule, while
PREVIOUS_RULE_END points to the *end* of the previous rule (NULL). */
/* The rule currently being defined, and the previous rule.
CURRENT_RULE points to the first LHS of the current rule, while
PREVIOUS_RULE_END points to the *end* of the previous rule (NULL). */
- grammar_symbol_append (lhs, loc);
+
+ p = grammar_symbol_append (lhs, loc);
+ if (lhs_name)
+ assign_named_ref(p, lhs_name);
+
symbol *dummy = dummy_symbol_get (dummy_location);
symbol_list *midrule = symbol_list_sym_new (dummy, dummy_location);
symbol *dummy = dummy_symbol_get (dummy_location);
symbol_list *midrule = symbol_list_sym_new (dummy, dummy_location);
/* Make a new rule, whose body is empty, before the current one, so
that the action just read can belong to it. */
++nrules;
/* Make a new rule, whose body is empty, before the current one, so
that the action just read can belong to it. */
++nrules;
code_props_rule_action_init (&midrule->action_props,
current_rule->action_props.code,
current_rule->action_props.location,
code_props_rule_action_init (&midrule->action_props,
current_rule->action_props.code,
current_rule->action_props.location,
/* Insert the dummy nonterminal replacing the midrule action into
the current rule. Bind it to its dedicated rule. */
/* Insert the dummy nonterminal replacing the midrule action into
the current rule. Bind it to its dedicated rule. */
grammar_end->midrule = midrule;
midrule->midrule_parent_rule = current_rule;
midrule->midrule_parent_rhs_index = symbol_list_length (current_rule->next);
grammar_end->midrule = midrule;
midrule->midrule_parent_rule = current_rule;
midrule->midrule_parent_rhs_index = symbol_list_length (current_rule->next);
- grammar_symbol_append (sym, loc);
+ p = grammar_symbol_append (sym, loc);
+ if (name)
+ assign_named_ref(p, name);
{
if (current_rule->action_props.code)
grammar_midrule_action ();
/* After all symbol declarations have been parsed, packgram invokes
code_props_translate_code. */
code_props_rule_action_init (¤t_rule->action_props, action, loc,
{
if (current_rule->action_props.code)
grammar_midrule_action ();
/* After all symbol declarations have been parsed, packgram invokes
code_props_translate_code. */
code_props_rule_action_init (¤t_rule->action_props, action, loc,
muscle_percent_define_default ("lr.keep-unreachable-states", "false");
{
char *lr_type;
/* IELR would be a better default, but LALR is historically the
default. */
muscle_percent_define_default ("lr.keep-unreachable-states", "false");
{
char *lr_type;
/* IELR would be a better default, but LALR is historically the
default. */
muscle_percent_define_default ("lr.default-reductions", "all");
else
muscle_percent_define_default ("lr.default-reductions", "accepting");
free (lr_type);
}
muscle_percent_define_default ("lr.default-reductions", "all");
else
muscle_percent_define_default ("lr.default-reductions", "accepting");
free (lr_type);
}
- "lr.type", "LALR", "IELR", "canonical LR", NULL,
+ "lr.type", "lalr", "ielr", "canonical-lr", NULL,
"lr.default-reductions", "all", "consistent", "accepting", NULL,
NULL
};
muscle_percent_define_check_values (values);
}
"lr.default-reductions", "all", "consistent", "accepting", NULL,
NULL
};
muscle_percent_define_check_values (values);
}