for (i = 0; i < snritems; i++)
{
+ bool printed = false;
item_number *sp;
item_number *sp1;
rule_number r;
sp++;
r = item_number_as_rule_number (*sp);
-
- xml_printf (out, level + 1, "<rule number=\"%d\">",
- rules[r].number);
-
- rule_lhs_print_xml (&rules[r], out, level + 2);
-
- xml_puts (out, level + 2, "<rhs>");
- for (sp = rules[r].rhs; sp < sp1; sp++)
- xml_printf (out, level + 3, "<symbol class=\"%s\">%s</symbol>",
- symbol_class_get_string (symbols[*sp]),
- xml_escape (symbols[*sp]->tag));
- xml_puts (out, level + 3, "<point/>");
- for (/* Nothing */; *sp >= 0; ++sp)
- xml_printf (out, level + 3, "<symbol class=\"%s\">%s</symbol>",
- symbol_class_get_string (symbols[*sp]),
- xml_escape (symbols[*sp]->tag));
-
- xml_puts (out, level + 2, "</rhs>");
+ 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,
+ "<item rule-number=\"%d\" point=\"%d\">",
+ rules[r].number, sp1 - sp);
+ state_rule_lookahead_tokens_print_xml (s, &rules[r],
+ out, level + 2);
+ xml_puts (out, level + 1, "</item>");
+ printed = true;
+ }
+ }
- xml_puts (out, level + 1, "</rule>");
+ if (!printed)
+ {
+ xml_printf (out, level + 1,
+ "<item rule-number=\"%d\" point=\"%d\"/>",
+ rules[r].number,
+ sp1 - sp);
+ }
}
xml_puts (out, level, "</itemset>");
}
item_number *rhsp;
xml_printf (out, level + 2,
- "<terminal type=\"%d\" symbol=\"%s\">",
- i, xml_escape (tag));
+ "<terminal symbol-number=\"%d\" token-number=\"%d\""
+ " name=\"%s\">",
+ token_translations[i], i, xml_escape (tag));
for (r = 0; r < nrules; r++)
for (rhsp = rules[r].rhs; *rhsp >= 0; rhsp++)
}
xml_printf (out, level + 2,
- "<nonterminal type=\"%d\" symbol=\"%s\">",
+ "<nonterminal symbol-number=\"%d\" name=\"%s\">",
i, xml_escape (tag));
if (left_count > 0)
/* 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);