X-Git-Url: https://git.saurik.com/bison.git/blobdiff_plain/f16b08196c780556cbf50691e2944960aebc46f6..d0ee410565c9d7bc876af42583ee092568f44fa8:/src/state.c diff --git a/src/state.c b/src/state.c index 076600c6..aa392aec 100644 --- a/src/state.c +++ b/src/state.c @@ -26,6 +26,7 @@ #include "complain.h" #include "gram.h" #include "state.h" +#include "print-xml.h" /*-------------------. @@ -143,6 +144,7 @@ state_new (symbol_number accessing_symbol, res->errs = NULL; res->consistent = 0; res->solved_conflicts = NULL; + res->solved_conflicts_xml = NULL; res->nitems = nitems; memcpy (res->items, core, items_size); @@ -244,6 +246,30 @@ state_rule_lookahead_tokens_print (state *s, rule *r, FILE *out) } } +void +state_rule_lookahead_tokens_print_xml (state *s, rule *r, + FILE *out, int level) +{ + /* Find the reduction we are handling. */ + reductions *reds = s->reductions; + int red = state_reduction_find (s, r); + + /* Print them if there are. */ + if (reds->lookahead_tokens && red != -1) + { + bitset_iterator biter; + int k; + xml_puts (out, level, ""); + BITSET_FOR_EACH (biter, reds->lookahead_tokens[red], k, 0) + { + xml_printf (out, level + 1, "%s", + symbol_class_get_string (symbols[k]), + xml_escape (symbols[k]->tag)); + } + xml_puts (out, level, ""); + } +} + /*---------------------. | A state hash table. |