0

There is one problem with the railroad diagram generator. When given a grammar, you may have to tweak it, and subsequently modify it several times. This would be done more quickly locally.

Is there a place where I can download the source code used by the site to generate railroad diagrams?

1 Answers1

0

I can't tell you about this particular online tool you mention. However, I can show you how you can easily generate your own (and beautiful) railroad diagrams using a tcl/tk script. It generates postscript output. The script does require the grammar to be entered inline in form of tcl lists but this is rather simple to do.

The original script came from the SQLite project but that doesn't have any documentation how to adapt it to your own needs. I modified it for a project I am involved in, tweaking the finer details to produce nicer looking output and adding detailed comments how to adapt it for your own grammar.

The script is here: https://bitbucket.org/trijezdci/m2r10/src/tip/_GRAMMAR/modula2_syntax_diagrams.tcl

The documentation I added is inline and starts at line 42.

Output generated by the script can be seen here:

http://modula-2.net/m2r10/pmwiki.php?n=SyntaxDiagrams.NonTerminals

One interesting feature of the generator that I have not found anywhere else is the ability to wrap around a long diagram so that it won't go off the page which is useful when you want to paste this into documents that people might want to print. This wrap around can be seen here:

http://modula-2.net/m2r10/pmwiki.php?n=SyntaxDiagrams.NonTerminals#definitionModule

hope this helps

trijezdci
  • 5,284
  • 2
  • 19
  • 15