xml: documentation

The XML output combined with the XSL Transformations provided in data/ are
incredibly useful, they should be documented.

* doc/bison.texi (Xml): New node.
This commit is contained in:
Theophile Ranquet
2012-10-22 17:37:57 +00:00
committed by Akim Demaille
parent d42fe46ec3
commit 9c16d39944
2 changed files with 60 additions and 1 deletions

7
NEWS
View File

@@ -42,7 +42,7 @@ GNU Bison NEWS
position_type are deprecated in favor of api.location.type and position_type are deprecated in favor of api.location.type and
api.position.type. api.position.type.
** Graphviz improvements ** Graph improvements in DOT and XSLT
The graphical presentation of the states is more readable: their shape is The graphical presentation of the states is more readable: their shape is
now rectangular, the state number is clearly displayed, and the items are now rectangular, the state number is clearly displayed, and the items are
@@ -51,6 +51,11 @@ GNU Bison NEWS
The reductions are now explicitly represented as transitions to other The reductions are now explicitly represented as transitions to other
diamond shaped nodes. diamond shaped nodes.
These changes are present in both --graph output and xml2dot.xsl XSLT
processing, with minor (documented) differences.
Two nodes were added to the documentation: Xml and Graphviz.
* Noteworthy changes in release 2.6.5 (2012-11-07) [stable] * Noteworthy changes in release 2.6.5 (2012-11-07) [stable]
We consider compiler warnings about Bison generated parsers to be bugs. We consider compiler warnings about Bison generated parsers to be bugs.

View File

@@ -295,6 +295,7 @@ Debugging Your Parser
* Understanding:: Understanding the structure of your parser. * Understanding:: Understanding the structure of your parser.
* Graphviz:: Getting a visual representation of the parser. * Graphviz:: Getting a visual representation of the parser.
* Xml:: Getting a markup representation of the parser.
* Tracing:: Tracing the execution of your parser. * Tracing:: Tracing the execution of your parser.
Tracing Your Parser Tracing Your Parser
@@ -8095,6 +8096,7 @@ automaton, and how to enable and understand the parser run-time traces.
@menu @menu
* Understanding:: Understanding the structure of your parser. * Understanding:: Understanding the structure of your parser.
* Graphviz:: Getting a visual representation of the parser. * Graphviz:: Getting a visual representation of the parser.
* Xml:: Getting a markup representation of the parser.
* Tracing:: Tracing the execution of your parser. * Tracing:: Tracing the execution of your parser.
@end menu @end menu
@@ -8511,6 +8513,9 @@ precedence of @samp{/} with respect to @samp{+}, @samp{-}, and
@samp{*}, but also because the @samp{*}, but also because the
associativity of @samp{/} is not specified. associativity of @samp{/} is not specified.
Note that Bison may also produce an HTML version of this output, via an XML
file and XSLT processing (@pxref{Xml}).
@c ================================================= Graphical Representation @c ================================================= Graphical Representation
@node Graphviz @node Graphviz
@@ -8618,6 +8623,55 @@ is shown as a blue diamond, labelled "Acc".
The @samp{go to} jump transitions are represented as dotted lines bearing The @samp{go to} jump transitions are represented as dotted lines bearing
the name of the rule being jumped to. the name of the rule being jumped to.
Note that a DOT file may also be produced via an XML file and XSLT
processing (@pxref{Xml}).
@c ================================================= XML
@node Xml
@section Visualizing your parser in multiple formats
@cindex xml
Bison supports two major report formats: textual output
(@pxref{Understanding}) when invoked with option @option{--verbose}, and DOT
(@pxref{Graphviz}) when invoked with option @option{--graph}. However,
another alternative is to output an XML file that may then be, with
@command{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 @file{.output} and DOT files obtained via
XSLT have no difference whatsoever with those obtained by invoking bison
with options @option{--verbose} or @option{--graph}.
The textual file is generated when the options @option{-x} or
@option{--xml[=FILE]} are specified, see @ref{Invocation,,Invoking Bison}.
If not specified, its name is made by removing @samp{.tab.c} or @samp{.c}
from the parser implementation file name, and adding @samp{.xml} instead.
For instance, if the grammar file is @file{foo.y}, the default XML output
file is @file{foo.xml}.
Bison ships with a @file{data/xslt} directory, containing XSL Transformation
files to apply to the XML file. Their names are non-ambiguous:
@table @file
@item xml2dot.xsl
Used to output a DOT version of the automaton. This might not be exactly the
same as the one obtained through @option{--graph}.
@item xml2text.xsl
Used to output a copy of the .output file.
@item xml2xhtml.xsl
Used to output an xhtml enhancement of the .output file.
@end table
Sample usage (requires @code{xsltproc}):
@example
$ bison -x input.y
@group
$ bison --print-datadir
/usr/local/share/bison
@end group
$ xsltproc /usr/local/share/bison/xslt/xml2xhtml.xsl input.xml > input.html
@end example
@c ================================================= Tracing @c ================================================= Tracing
@node Tracing @node Tracing