summaryrefslogtreecommitdiff
path: root/src/gram.h
diff options
context:
space:
mode:
authorAkim Demaille <akim.demaille@gmail.com>2019-01-28 19:05:38 +0100
committerAkim Demaille <akim.demaille@gmail.com>2019-01-30 07:06:48 +0100
commite1783bc6863c06aaeaa0b672c2f02a648772665f (patch)
treeb62b1ce36e0361c305dc80b10068573796faf7c2 /src/gram.h
parentc4f143eb967a31c6b9e9643e1f86b821159483ed (diff)
downloadbison-e1783bc6863c06aaeaa0b672c2f02a648772665f.tar.gz
gram: factor the printing of items and the computation of their rule
There are several places where we need to recover the rule from an item, let's factor that into item_rule. We also want to print items in a nice way: we do it when generating the *output file, but it is also useful in debug messages. * src/gram.h, src/gram.c (item_rule, item_print): New. * src/print.c (print_core): Use them. * src/state.h, src/state.c: Propagate constness.
Diffstat (limited to 'src/gram.h')
-rw-r--r--src/gram.h10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/gram.h b/src/gram.h
index 3210b494..f7918cd5 100644
--- a/src/gram.h
+++ b/src/gram.h
@@ -166,6 +166,7 @@ item_number_is_rule_number (item_number i)
return i < 0;
}
+
/*--------.
| Rules. |
`--------*/
@@ -207,6 +208,15 @@ typedef struct
extern rule *rules;
+/* Get the rule associated to this item. ITEM points inside RITEM. */
+rule const *item_rule (item_number const *item);
+
+/* 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
+ case LHS is factored. Passing NULL is fine. */
+void item_print (item_number *item, rule const *previous_rule,
+ FILE *out);
+
/* A function that selects a rule. */
typedef bool (*rule_filter) (rule const *);