mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-14 23:03:04 +00:00
* src/gram.c (rule_rhs_print_xml): Now static, since it isn't used
elsewhere. * src/print-xml.c: Prefer "const" after types; that's more consistent. (xml_printf): Indent just 1 space for level. (e_char, xlate_char): Remove. (xml_escape_string): Rewrite to avoid undefined behavior (used storage that was freed from the stack). (xml_escape_n): Don't bother checking for subscript error. 2007-09-21 Wojciech Polak <polak@gnu.org> Add support for an -x option to generate an XML report. It is not documented yet. * src/print-xml.c: New file. * src/print-xml.h: Likewise. * lib/timevar.def (TV_XML): New var. * src/Makefile.am (bison_SOURCES): Add print-xml.c, print-xml.h. * src/conflicts.c: Include print-xml.h. (solved_conflicts_xml_obstack): New var. (log_resolution, conflicts_solve, conflicts_free): Add support for XML report. (conflicts_output_val): New function. * src/conflicts.h (conflicts_output_val): New decl. * src/files.c (spec_xml_file): New var. (compute_output_file_names, output_file_names_free): Add XML support. * src/files.h (spec_xml_file): New decl. * src/getargs.c (xml_flag): New var. (usage, short_options, long_options, getargs): Add XML support. * src/getargs.h (xml_flag): New decl. * src/gram.c: Include print-xml.h. (rule_lhs_print_xml, rule_rhs_print_xml): (grammar_rules_partial_print_xml, grammar_rules_print_xml): New functions. * src/gram.h: Declare external ones. * src/main.c: Include print-xml.h. (main): Add XML support. * src/reduce.c: Include print-xml.h. (reduce_xml): New function. * src/reduce.h: Declare it. * src/state.c: Include print-xml.h. (state_new): Add XML support. (state_rule_lookahead_tokens_print_xml): New function. * src/state.h: Declare it. (struct state): New member solved_conflicts_xml. * src/symtab.c (symbol_class_get_string): New function. * src/symtab.h: Declare it. 2007-09-21 Paul Eggert <eggert@cs.ucla.edu>
This commit is contained in:
59
src/reduce.c
59
src/reduce.c
@@ -1,7 +1,7 @@
|
||||
/* Grammar reduction for Bison.
|
||||
|
||||
Copyright (C) 1988, 1989, 2000, 2001, 2002, 2003, 2005, 2006 Free
|
||||
Software Foundation, Inc.
|
||||
Copyright (C) 1988, 1989, 2000, 2001, 2002, 2003, 2005, 2006,
|
||||
2007 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of Bison, the GNU Compiler Compiler.
|
||||
|
||||
@@ -35,6 +35,7 @@
|
||||
#include "files.h"
|
||||
#include "getargs.h"
|
||||
#include "gram.h"
|
||||
#include "print-xml.h"
|
||||
#include "reader.h"
|
||||
#include "reduce.h"
|
||||
#include "symtab.h"
|
||||
@@ -374,8 +375,62 @@ reduce_output (FILE *out)
|
||||
}
|
||||
|
||||
|
||||
/*--------------------------------------------------------------.
|
||||
| Output the detailed results of the reductions. For FILE.xml. |
|
||||
`---------------------------------------------------------------*/
|
||||
|
||||
void
|
||||
reduce_xml (FILE *out, int level)
|
||||
{
|
||||
fputc ('\n', out);
|
||||
xml_puts (out, level, "<reductions>");
|
||||
xml_puts (out, level + 1, "<useless>");
|
||||
|
||||
if (nuseless_nonterminals > 0)
|
||||
{
|
||||
int i;
|
||||
xml_puts (out, level + 2, "<nonterminals>");
|
||||
for (i = 0; i < nuseless_nonterminals; ++i)
|
||||
xml_printf (out, level + 3,
|
||||
"<nonterminal>%s</nonterminal>",
|
||||
symbols[nsyms + i]->tag);
|
||||
xml_puts (out, level + 2, "</nonterminals>");
|
||||
}
|
||||
else
|
||||
xml_puts (out, level + 2, "<nonterminals/>");
|
||||
|
||||
if (nuseless_productions > 0)
|
||||
grammar_rules_partial_print_xml (out, level + 1, true, rule_useless_p);
|
||||
else
|
||||
xml_puts (out, level + 2, "<rules/>");
|
||||
|
||||
xml_puts (out, level + 1, "</useless>");
|
||||
xml_puts (out, level + 1, "<unused>");
|
||||
|
||||
{
|
||||
bool b = false;
|
||||
int i;
|
||||
for (i = 0; i < ntokens; i++)
|
||||
if (!bitset_test (V, i) && !bitset_test (V1, i))
|
||||
{
|
||||
if (!b)
|
||||
xml_puts (out, level + 2, "<terminals>");
|
||||
b = true;
|
||||
xml_printf (out, level + 3,
|
||||
"<terminal>%s</terminal>",
|
||||
symbols[i]->tag);
|
||||
}
|
||||
if (b)
|
||||
xml_puts (out, level + 2, "</terminals>");
|
||||
else
|
||||
xml_puts (out, level + 2, "<terminals/>");
|
||||
}
|
||||
|
||||
xml_puts (out, level + 1, "</unused>");
|
||||
xml_puts (out, level, "</reductions>");
|
||||
fputc ('\n', out);
|
||||
}
|
||||
|
||||
|
||||
/*-------------------------------.
|
||||
| Report the results to STDERR. |
|
||||
|
||||
Reference in New Issue
Block a user