X-Git-Url: https://git.saurik.com/bison.git/blobdiff_plain/34cdeddfa54df8c85b20bf013a0b82053a5148f2..d0ee410565c9d7bc876af42583ee092568f44fa8:/src/print-xml.c diff --git a/src/print-xml.c b/src/print-xml.c index 81f4d803..da8bfcab 100644 --- a/src/print-xml.c +++ b/src/print-xml.c @@ -108,6 +108,7 @@ print_core (FILE *out, int level, state *s) for (i = 0; i < snritems; i++) { + bool printed = false; item_number *sp; item_number *sp1; rule_number r; @@ -118,30 +119,34 @@ print_core (FILE *out, int level, state *s) sp++; r = item_number_as_rule_number (*sp); - - xml_printf (out, level + 1, "", - rules[r].number); - - rule_lhs_print_xml (&rules[r], out, level + 2); - - xml_puts (out, level + 2, ""); - for (sp = rules[r].rhs; sp < sp1; sp++) - xml_printf (out, level + 3, "%s", - symbol_class_get_string (symbols[*sp]), - xml_escape (symbols[*sp]->tag)); - xml_puts (out, level + 3, ""); - for (/* Nothing */; *sp >= 0; ++sp) - xml_printf (out, level + 3, "%s", - symbol_class_get_string (symbols[*sp]), - xml_escape (symbols[*sp]->tag)); - - xml_puts (out, level + 2, ""); + sp = rules[r].rhs; /* Display the lookahead tokens? */ - if (report_flag & report_lookahead_tokens) - state_rule_lookahead_tokens_print_xml (s, &rules[r], out, level + 2); + if (report_flag & report_lookahead_tokens + && item_number_is_rule_number (*sp1)) + { + reductions *reds = s->reductions; + int red = state_reduction_find (s, &rules[r]); + /* Print item with lookaheads if there are. */ + if (reds->lookahead_tokens && red != -1) + { + xml_printf (out, level + 1, + "", + rules[r].number, sp1 - sp); + state_rule_lookahead_tokens_print_xml (s, &rules[r], + out, level + 2); + xml_puts (out, level + 1, ""); + printed = true; + } + } - xml_puts (out, level + 1, ""); + if (!printed) + { + xml_printf (out, level + 1, + "", + rules[r].number, + sp1 - sp); + } } xml_puts (out, level, ""); } @@ -424,8 +429,9 @@ print_grammar (FILE *out, int level) item_number *rhsp; xml_printf (out, level + 2, - "", - i, xml_escape (tag)); + "", + token_translations[i], i, xml_escape (tag)); for (r = 0; r < nrules; r++) for (rhsp = rules[r].rhs; *rhsp >= 0; rhsp++) @@ -460,7 +466,7 @@ print_grammar (FILE *out, int level) } xml_printf (out, level + 2, - "", + "", i, xml_escape (tag)); if (left_count > 0) @@ -584,9 +590,6 @@ print_xml (void) /* print rules never reduced */ print_rules_never_reduced (out, level + 1); - /* print conflicts */ - conflicts_output_xml (out, level + 1); - /* print grammar */ print_grammar (out, level + 1);