diff options
author | Joel E. Denny <jdenny@ces.clemson.edu> | 2007-11-24 19:41:25 +0000 |
---|---|---|
committer | Joel E. Denny <jdenny@ces.clemson.edu> | 2007-11-24 19:41:25 +0000 |
commit | d80fb37a26b24d8aa7a4428389a6004c7f2e93be (patch) | |
tree | 12e7fd4853e969a5b7c99d2437353b1a0a1ba5cf /src/print-xml.c | |
parent | 1bb2bd75f0185ca53c92f1c63cdc0b5ceef3f1f2 (diff) | |
download | bison-d80fb37a26b24d8aa7a4428389a6004c7f2e93be.tar.gz |
In the XML output, list useless and unused symbols and rules with the
useful ones and add a "usefulness" attribute. Discussed starting at
<http://lists.gnu.org/archive/html/bison-patches/2007-09/msg00017.html>.
* src/gram.c (grammar_rules_partial_print_xml): Remove.
(grammar_rules_print_xml): Print all rules instead of just those
useful in the grammar, and add a "usefulness" attribute.
* src/gram.h (grammar_rules_partial_print_xml): Remove prototype.
* src/print-xml.c (print_rules_useless_in_parser): Remove.
(print_grammar): Print all nonterminals instead of just useful ones,
and add a "usefulness" attribute to nonterminals and terminals.
(print_xml): Don't print a separate "reductions" or
"rules-useless-in-parser" element.
* src/reduce.c (reduce_output): Use reduce_token_unused_in_grammar.
(reduce_xml): Remove.
(reduce_token_unused_in_grammar): New.
(reduce_nonterminal_useless_in_grammar): New.
* src/reduce.h (reduce_xml): Remove prototype.
(reduce_token_unused_in_grammar): Add prototype.
(reduce_nonterminal_useless_in_grammar): Add prototype.
* data/xslt/xml2text.xsl: Update for XML changes.
* data/xslt/xml2xhtml.xsl: Update for XML changes.
* tests/reduce.at (Useless Terminals): Update output.
(Useless Rules): Update output.
(Reduced Automaton): Update output.
Say "Terminals unused in grammar" instead of "Unused terminals".
* NEWS (2.3a+): Update.
* doc/bison.texinfo (Understanding): Update example output.
* src/reduce.c (reduce_output): Implement.
* data/xslt/xml2text.xsl: Implement.
* data/xslt/xml2xhtml.xsl: Implement.
Diffstat (limited to 'src/print-xml.c')
-rw-r--r-- | src/print-xml.c | 50 |
1 files changed, 10 insertions, 40 deletions
diff --git a/src/print-xml.c b/src/print-xml.c index f7cae3f0..ff2bacd9 100644 --- a/src/print-xml.c +++ b/src/print-xml.c @@ -52,35 +52,6 @@ static struct escape_buf escape_bufs[2]; /*--------------------------------. -| Print rules useless in parser. | -`--------------------------------*/ - -static void -print_rules_useless_in_parser (FILE *out, int level) -{ - rule_number r; - bool count = false; - - for (r = 0; r < nrules + nuseless_productions; r++) - { - if (rule_useless_in_parser_p (&rules[r])) - { - count = true; - break; - } - } - - if (count) { - xml_puts (out, level, "<rules-useless-in-parser>"); - grammar_rules_partial_print_xml (out, level - 1, - false, rule_useless_in_parser_p); - xml_puts (out, level, "</rules-useless-in-parser>"); - } - else - xml_puts (out, level, "<rules-useless-in-parser/>"); -} - -/*--------------------------------. | Report information on a state. | `--------------------------------*/ @@ -430,8 +401,10 @@ print_grammar (FILE *out, int level) xml_printf (out, level + 2, "<terminal symbol-number=\"%d\" token-number=\"%d\"" - " name=\"%s\">", - token_translations[i], i, xml_escape (tag)); + " name=\"%s\" usefulness=\"%s\">", + token_translations[i], i, xml_escape (tag), + reduce_token_unused_in_grammar (token_translations[i]) + ? "unused-in-grammar" : "useful"); for (r = 0; r < nrules; r++) for (rhsp = rules[r].rhs; *rhsp >= 0; rhsp++) @@ -446,7 +419,7 @@ print_grammar (FILE *out, int level) /* Nonterminals */ xml_puts (out, level + 1, "<nonterminals>"); - for (i = ntokens; i < nsyms; i++) + for (i = ntokens; i < nsyms + nuseless_nonterminals; i++) { int left_count = 0, right_count = 0; rule_number r; @@ -466,8 +439,11 @@ print_grammar (FILE *out, int level) } xml_printf (out, level + 2, - "<nonterminal symbol-number=\"%d\" name=\"%s\">", - i, xml_escape (tag)); + "<nonterminal symbol-number=\"%d\" name=\"%s\"" + " usefulness=\"%s\">", + i, xml_escape (tag), + reduce_nonterminal_useless_in_grammar (i) + ? "useless-in-grammar" : "useful"); if (left_count > 0) { @@ -584,12 +560,6 @@ print_xml (void) xml_printf (out, level + 1, "<filename>%s</filename>", xml_escape (grammar_file)); - /* print reductions */ - reduce_xml (out, level + 1); - - /* print rules useless in parser */ - print_rules_useless_in_parser (out, level + 1); - /* print grammar */ print_grammar (out, level + 1); |