showgrammar is a Python script to convert a yacc grammar to syntax diagrams, also known as railroad diagrams.
The program is open source, and comes with the same amount of guarantees as the amount of money you paid for it (namely none).
While it is still a nice piece of software I have no need for it at the moment.
Issues are recorded (below), but don't expect bug fixes unless you write the patch.
- First release (Id: 1.1)
In order to be able to run the showgrammar script, you'll need
Also, since the script generates LaTeX using the PStricks package, you should have both installed on your system.
- The Python language (www.python.org).
- The Python Spark package, written by John Aycock. His web site for
this package is http://www.cpsc.ucalgary.ca/~aycock/spark.
However, if you live on the european side of the big pond, and only want a copy of the
spark-0.6.1.tar.gz software, you can use my local copy.
- A clean yacc grammar.
If you have a grammar polluted with interfacing
code, you may want to try to use the stripgrammar.l
scanner generator file to cleanup the grammar first.
- The Python showgrammar.py script (duh)
- The showgrammar.1 html man page (sorry, no real showgrammar(1) yet).
As an extremely simple example, I converted the yacc grammar used to read the input file to syntax diagrams. See the yaccgram.y, yaccgram.tex, and yaccgram.ps files to see the conversion process in action.
Known issues and possible enhancements
The software is not fool proof yet:
- Literals in productions are not supported
- Use of under score ('_') in non-terminals breaks the scanner (reported by Ben)
- Use of digits in terminals breaks LaTeX (reported by Ben)
- Switch to another parser (eg PLY). The scanner of Spark is very weak.
- Generate output for the CTAN railroad package, which produces much better output.
You can send me an email at firstname.lastname@example.org.