void
grammar_current_rule_begin (symbol *lhs, location loc)
{
- if (!start_flag)
- {
- startsymbol = lhs;
- startsymbol_location = loc;
- start_flag = true;
- }
-
/* Start a new rule and record its lhs. */
++nrules;
previous_rule_end = grammar_end;
endtoken->user_token_number = 0;
}
+ /* Find the start symbol if no %start. */
+ if (!start_flag)
+ {
+ symbol_list *node;
+ for (node = grammar;
+ node != NULL && symbol_is_dummy (node->sym);
+ node = node->next)
+ {
+ for (node = node->next;
+ node != NULL && node->sym != NULL;
+ node = node->next)
+ ;
+ }
+ assert (node != NULL);
+ grammar_start_symbol_set (node->sym, node->sym->location);
+ }
+
/* Insert the initial rule, whose line is that of the first rule
(not that of the start symbol):