How to pretty-print a grammar.
Description
A grammar can be pretty-printed (to plain text, html, or latex) using the GPP package in the following way:
Alternatively, a grammar can be pretty-printed using the ast2abox? tool:
Examples
Assuming G.tbl is the parse table for a grammar of language L and G.pp is the corresponding pretty-print table. A term T.sdf over langauge L can be pretty-printed to text, html and latex in the following way:
# sglr -2 -p G.tbl -i T.sdf -o T.asfix # implode-asfix -i T.asfix -o T.af # ast2abox -p G.pp -i T.af -o T.sdf.abox # abox2text -i T.sdf.abox -o T.sdf.text # abox2html -i T.sdf.abox -o T.sdf.html # abox2latex -i T.sdf.abox -o T.sdf.tex
The file T.sdf.tex can be included in a latex document, which has the following package statement in its preamble:
\usepackage{boxenv}In the file T.sdf.tex you can read where to find the file boxenv.sty (See HowToUseGPPWithLaTeX).
See also