I’d like to visualize a grammar file (actually the Jison grammar for coffee-script). So the input file is a grammar file of Bison/Yacc style. The expected output could be a Graphviz dot file or something similar.
I’m not necessarily looking for a complete IDE, like GOLD. But it’s important to be able to handle a LALR input, that’s why the excellent ANLTRWorks doesn’t come into account.
I also checked a comparison of parsers on Wikipedia, but it includes only IDE support, but not visualization.
This is the coffeescript grammar file I actually want to visualize.
Here are the instructions for creating a syntax diagram.
The content of grammar.coffee is executable code, which must be run for getting the actual Jison grammar. I used the Try CoffeeScript page to compile it, after having replaced the Jison call by a Javascript alert. Then ran the resulting Javascript to obtain the grammar, which
looks like this:
The above can be fed to the Jison-to-W3C grammar converter, resulting
in a grammar like this:
From here we can have the Railroad Diagram Generator create a syntax diagram:
. . .
Note that the converter only evaluates the “bnf” part of the grammar, so it does not take the token definitions into account. This could be improved by doing some manual postprocessing of the W3C-style grammar.