Update: Nowadays, the original RR is available on Maven Central and offers an embeddable library. Therefore, this fork has served its purpose. 🎉
Trako is a generator of syntax diagrams, also known as railroad diagrams.
Besides generating diagrams from EBNF rules, Trako can also perform some grammar transformation, e.g. factorization and elimination of direct recursion. To some extent this transforms BNF to EBNF, yielding more compact diagrams.
️Trako is based on the excellent RR by Gunther Rademacher. Trako was created to make the RR diagram generator available to other applications and to add distribution via Maven Central. Since PR #14 and PR #22 were merged, Trako is no longer needed.
By the way, the name "Trako" is the word for "track" in Esperanto.
Here are two examples of generated diagrams (taken from the Python grammar):
if_stmt:
try_stmt:
Trako accepts grammars in W3C-style EBNF. Some other representations, including some parser generator input notations, can be converted to W3C-style using Grammar Conversion.
There are two flavors of Trako: a library for use with other applications and an all-in-one JAR for CLI use. Both are available on Maven Central.
In the examples below, VERSION must be replaced with the desired version.
via Maven:
<dependency>
<groupId>com.github.bannmann.trako</groupId>
<artifactId>trako</artifactId>
<version>VERSION</version>
</dependency>
To generate a diagram, run e.g.
java -jar trako-VERSION-all.jar grammar.ebnfFor listing the full set of available options, run
java -jar trako-VERSION-all.jarwithout further command line arguments.
Trako is released under the Apache 2 License.
