* 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:
Paul Eggert
2007-09-21 22:53:58 +00:00
parent 6d8e724de2
commit 41d7a5f24d
20 changed files with 1045 additions and 15 deletions

View File

@@ -48,6 +48,7 @@
bool debug_flag;
bool defines_flag;
bool graph_flag;
bool xml_flag;
bool locations_flag;
bool no_lines_flag;
bool token_table_flag;
@@ -285,6 +286,7 @@ Output:\n\
-b, --file-prefix=PREFIX specify a PREFIX for output files\n\
-o, --output=FILE leave output to FILE\n\
-g, --graph also output a graph of the automaton\n\
-x, --xml also output an xml of the automaton\n\
\n\
"), stdout);
@@ -387,7 +389,7 @@ language_argmatch (char const *arg, int prio, location const *loc)
`----------------------*/
/* Shorts options. */
static char const short_options[] = "yvegdhr:L:ltknVo:b:p:S:T::W";
static char const short_options[] = "yvegxdhr:L:ltknVo:b:p:S:T::W";
/* Values for long options that do not have single-letter equivalents. */
enum
@@ -413,6 +415,7 @@ static struct option const long_options[] =
{ "output", required_argument, 0, 'o' },
{ "output-file", required_argument, 0, 'o' },
{ "graph", optional_argument, 0, 'g' },
{ "xml", optional_argument, 0, 'x' },
{ "report", required_argument, 0, 'r' },
{ "verbose", no_argument, 0, 'v' },
@@ -470,6 +473,13 @@ getargs (int argc, char *argv[])
spec_graph_file = xstrdup (AS_FILE_NAME (optarg));
break;
case 'x':
/* Here, the -x and --xml=FILE options are differentiated. */
xml_flag = true;
if (optarg)
spec_xml_file = xstrdup (AS_FILE_NAME (optarg));
break;
case 'h':
usage (EXIT_SUCCESS);