mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-11 21:33:04 +00:00
add support for --html
* bootstrap.conf: We need the "execute" module. * src/files.h, src/files.c (spec_html_file, html_flag): New. * src/getargs.h, src/getargs.c (--html): New. * src/print-xml.h, src/print-xml.c (print_html): New. * src/main.c: Use them. * tests/output.at, tests/report.at: Check --html.
This commit is contained in:
@@ -55,6 +55,7 @@ char const *spec_name_prefix = NULL; /* for -p. */
|
||||
location spec_name_prefix_loc = EMPTY_LOCATION_INIT;
|
||||
char *spec_verbose_file = NULL; /* for --verbose. */
|
||||
char *spec_graph_file = NULL; /* for -g. */
|
||||
char *spec_html_file = NULL; /* for --html. */
|
||||
char *spec_xml_file = NULL; /* for -x. */
|
||||
char *spec_header_file = NULL; /* for --header. */
|
||||
char *spec_mapped_header_file = NULL;
|
||||
@@ -425,6 +426,13 @@ compute_output_file_names (void)
|
||||
output_file_name_check (&spec_graph_file, false);
|
||||
}
|
||||
|
||||
if (html_flag)
|
||||
{
|
||||
if (! spec_html_file)
|
||||
spec_html_file = concat2 (all_but_tab_ext, ".html");
|
||||
output_file_name_check (&spec_html_file, false);
|
||||
}
|
||||
|
||||
if (xml_flag)
|
||||
{
|
||||
if (! spec_xml_file)
|
||||
@@ -526,6 +534,7 @@ output_file_names_free (void)
|
||||
free (all_but_ext);
|
||||
free (spec_verbose_file);
|
||||
free (spec_graph_file);
|
||||
free (spec_html_file);
|
||||
free (spec_xml_file);
|
||||
free (spec_header_file);
|
||||
free (spec_mapped_header_file);
|
||||
|
||||
@@ -44,7 +44,10 @@ extern char *spec_verbose_file;
|
||||
/* File name specified for the output graph. */
|
||||
extern char *spec_graph_file;
|
||||
|
||||
/* File name specified for the xml output. */
|
||||
/* File name specified for the HTML output. */
|
||||
extern char *spec_html_file;
|
||||
|
||||
/* File name specified for the XML output. */
|
||||
extern char *spec_xml_file;
|
||||
|
||||
/* File name specified with --header. */
|
||||
|
||||
@@ -40,6 +40,7 @@
|
||||
|
||||
bool header_flag = false;
|
||||
bool graph_flag = false;
|
||||
bool html_flag = false;
|
||||
bool xml_flag = false;
|
||||
bool no_lines_flag = false;
|
||||
bool token_table_flag = false;
|
||||
@@ -432,6 +433,7 @@ Output Files:\n\
|
||||
-b, --file-prefix=PREFIX specify a PREFIX for output files\n\
|
||||
-o, --output=FILE leave output to FILE\n\
|
||||
-g, --graph[=FILE] also output a graph of the automaton\n\
|
||||
--html[=FILE] also output an HTML report of the automaton\n\
|
||||
-x, --xml[=FILE] also output an XML report of the automaton\n\
|
||||
-M, --file-prefix-map=OLD=NEW replace prefix OLD with NEW when writing file paths\n\
|
||||
in output files\n\
|
||||
@@ -572,6 +574,7 @@ enum
|
||||
{
|
||||
COLOR_OPTION = CHAR_MAX + 1,
|
||||
FIXED_OUTPUT_FILES_OPTION,
|
||||
HTML_OPTION,
|
||||
LOCATIONS_OPTION,
|
||||
PRINT_DATADIR_OPTION,
|
||||
PRINT_LOCALEDIR_OPTION,
|
||||
@@ -616,6 +619,7 @@ static struct option const long_options[] =
|
||||
{ "file-prefix", required_argument, 0, 'b' },
|
||||
{ "output", required_argument, 0, 'o' },
|
||||
{ "graph", optional_argument, 0, 'g' },
|
||||
{ "html", optional_argument, 0, HTML_OPTION },
|
||||
{ "xml", optional_argument, 0, 'x' },
|
||||
{ "file-prefix-map", required_argument, 0, 'M' },
|
||||
|
||||
@@ -839,6 +843,16 @@ getargs (int argc, char *argv[])
|
||||
/* Handled in getargs_colors. */
|
||||
break;
|
||||
|
||||
case HTML_OPTION:
|
||||
html_flag = true;
|
||||
xml_flag = true;
|
||||
if (optarg)
|
||||
{
|
||||
free (spec_html_file);
|
||||
spec_html_file = xstrdup (optarg);
|
||||
}
|
||||
break;
|
||||
|
||||
case FIXED_OUTPUT_FILES_OPTION:
|
||||
complain (&loc, Wdeprecated,
|
||||
_("deprecated option: %s, use %s"),
|
||||
|
||||
@@ -36,6 +36,7 @@ extern char const *include;
|
||||
|
||||
extern bool header_flag; /* for -d/-H */
|
||||
extern bool graph_flag; /* for -g */
|
||||
extern bool html_flag; /* for --html */
|
||||
extern bool xml_flag; /* for -x */
|
||||
extern bool no_lines_flag; /* for -l */
|
||||
extern bool token_table_flag; /* for -k */
|
||||
|
||||
10
src/main.c
10
src/main.c
@@ -188,12 +188,20 @@ main (int argc, char *argv[])
|
||||
}
|
||||
|
||||
/* Output xml. */
|
||||
if (xml_flag)
|
||||
if (html_flag || xml_flag)
|
||||
{
|
||||
timevar_push (tv_xml);
|
||||
print_xml ();
|
||||
timevar_pop (tv_xml);
|
||||
}
|
||||
|
||||
/* Output html. */
|
||||
if (html_flag)
|
||||
{
|
||||
timevar_push (tv_html);
|
||||
print_html ();
|
||||
timevar_pop (tv_html);
|
||||
}
|
||||
}
|
||||
|
||||
/* Stop if there were errors, to avoid trashing previous output
|
||||
|
||||
@@ -27,12 +27,16 @@
|
||||
#include <stdarg.h>
|
||||
|
||||
#include "closure.h"
|
||||
#include "complain.h"
|
||||
#include "conflicts.h"
|
||||
#include "execute.h"
|
||||
#include "files.h"
|
||||
#include "getargs.h"
|
||||
#include "gram.h"
|
||||
#include "lalr.h"
|
||||
#include "lr0.h"
|
||||
#include "muscle-tab.h"
|
||||
#include "path-join.h"
|
||||
#include "print.h"
|
||||
#include "reader.h"
|
||||
#include "reduce.h"
|
||||
@@ -531,3 +535,41 @@ print_xml (void)
|
||||
|
||||
xfclose (out);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
print_html (void)
|
||||
{
|
||||
assert (xml_flag);
|
||||
|
||||
char *xml2html = xpath_join (pkgdatadir (), "xslt/xml2xhtml.xsl");
|
||||
|
||||
char const *argv[11];
|
||||
int i = 0;
|
||||
argv[i++] = muscle_percent_define_get ("tool.xsltproc");
|
||||
argv[i++] = "-o";
|
||||
argv[i++] = spec_html_file;
|
||||
argv[i++] = xml2html;
|
||||
argv[i++] = spec_xml_file;
|
||||
argv[i++] = NULL;
|
||||
aver (i <= ARRAY_CARDINALITY (argv));
|
||||
|
||||
if (trace_flag & trace_tools)
|
||||
{
|
||||
fputs ("running:", stderr);
|
||||
for (int j = 0; argv[j]; ++j)
|
||||
fprintf (stderr, " %s", argv[j]);
|
||||
fputc ('\n', stderr);
|
||||
}
|
||||
|
||||
int status
|
||||
= execute (argv[0],
|
||||
argv[0], (char **)(void*)(argv),
|
||||
/* ignore_sigpipe */ false,
|
||||
/* null_stdin, null_stdout, null_stderr */ true, true, true,
|
||||
/* slave_process */ true, /* exit_on_error */ false,
|
||||
NULL);
|
||||
if (status)
|
||||
complain (NULL, complaint, _("%s failed with status %d"), argv[0], status);
|
||||
free (xml2html);
|
||||
}
|
||||
|
||||
@@ -30,4 +30,7 @@ char const *xml_escape_n (int n, char const *str);
|
||||
char const *xml_escape (char const *str);
|
||||
void print_xml (void);
|
||||
|
||||
/* Use xsltproc to generate HTML from XML output. */
|
||||
void print_html (void);
|
||||
|
||||
#endif /* !PRINT_XML_H_ */
|
||||
|
||||
@@ -735,6 +735,7 @@ prepare_percent_define_front_end_variables (void)
|
||||
muscle_percent_define_default ("lr.default-reduction", "accepting");
|
||||
free (lr_type);
|
||||
}
|
||||
muscle_percent_define_default ("tool.xsltproc", "xsltproc");
|
||||
|
||||
/* Check %define front-end variables. */
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user