mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-18 00:33:03 +00:00
multistart: introduce and use rule_is_initial
* src/gram.h (rule_is_initial): New. * src/graphviz.c, src/print-xml.c, src/print.c, src/lalr.c: Use it. Some of these occurrences were incorrect (checking whether this is rule 0), and not behaving properly in the case of multistart.
This commit is contained in:
15
src/gram.h
15
src/gram.h
@@ -233,9 +233,24 @@ item_rule (item_number const *item)
|
||||
void item_print (item_number *item, rule const *previous_rule,
|
||||
FILE *out);
|
||||
|
||||
/*--------.
|
||||
| Rules. |
|
||||
`--------*/
|
||||
|
||||
/* A function that selects a rule. */
|
||||
typedef bool (*rule_filter) (rule const *);
|
||||
|
||||
/* Whether is an accepting rule (i.e., its reduction terminates
|
||||
parsing with success). */
|
||||
static inline bool
|
||||
rule_is_initial (rule const *r)
|
||||
{
|
||||
/* In the case of multistart, we need to check whether the LHS is
|
||||
$accept. In the case of "unistart", it would suffice to
|
||||
check whether this is rule number 0. */
|
||||
return r->lhs == acceptsymbol->content;
|
||||
}
|
||||
|
||||
/* Whether the rule has a 'number' smaller than NRULES. That is, it
|
||||
is useful in the grammar. */
|
||||
bool rule_useful_in_grammar_p (rule const *r);
|
||||
|
||||
Reference in New Issue
Block a user