style: factor the access to a rule from its items

* src/counterexample.c (item_rule): Move to...
* src/counterexample.h: here.
* src/AnnotationList.c, src/counterexample.c, src/ielr.c: Use it.
This commit is contained in:
Akim Demaille
2020-06-25 18:35:27 +02:00
parent 1001f48416
commit 8f44164443
5 changed files with 19 additions and 42 deletions

View File

@@ -237,7 +237,15 @@ print_dot (FILE *out)
}
/* Get the rule associated to this item. ITEM points inside RITEM. */
rule const *item_rule (item_number const *item);
static inline rule const *
item_rule (item_number const *item)
{
item_number const *sp = item;
while (!item_number_is_rule_number (*sp))
++sp;
rule_number r = item_number_as_rule_number (*sp);
return &rules[r];
}
/* Pretty-print this ITEM (as in the report). ITEM points inside
RITEM. PREVIOUS_RULE is used to see if the lhs is common, in which