Next: , Previous: , Up: Debugging   [Contents][Index]


8.3 Visualizing your parser in multiple formats

Bison supports two major report formats: textual output (see Understanding Your Parser) when invoked with option --verbose, and DOT (see Visualizing Your Parser) when invoked with option --graph. However, another alternative is to output an XML file that may then be, with xsltproc, rendered as either a raw text format equivalent to the verbose file, or as an HTML version of the same file, with clickable transitions, or even as a DOT. The .output and DOT files obtained via XSLT have no difference whatsoever with those obtained by invoking bison with options --verbose or --graph.

The XML file is generated when the options -x or --xml[=FILE] are specified, see Invoking Bison. If not specified, its name is made by removing ‘.tab.c’ or ‘.c’ from the parser implementation file name, and adding ‘.xml’ instead. For instance, if the grammar file is foo.y, the default XML output file is foo.xml.

Bison ships with a data/xslt directory, containing XSL Transformation files to apply to the XML file. Their names are non-ambiguous:

xml2dot.xsl

Used to output a copy of the DOT visualization of the automaton.

xml2text.xsl

Used to output a copy of the ‘.output’ file.

xml2xhtml.xsl

Used to output an xhtml enhancement of the ‘.output’ file.

Sample usage (requires xsltproc):

$ bison -x gr.y
$ bison --print-datadir
/usr/local/share/bison
$ xsltproc /usr/local/share/bison/xslt/xml2xhtml.xsl gr.xml >gr.html