JSyntrax is a railroad diagrams generator. It creates a visual illustration of the grammar used for programming languages. A specification file describes the syntax as a hierarchy of basic elements. This is processed into an image representing the same syntax with interconnected bubbles.
The specification is a set of nested Groovy function calls:
indentstack(10,
line(opt('-'), choice('0', line('1-9', loop(None, '0-9'))),
opt('.', loop('0-9', None))),
line(opt(choice('e', 'E'), choice(None, '+', '-'), loop('0-9', None)))
)
This is processed by JSyntrax to generate an SVG image:
JSyntrax can render to SVG vector images or PNG bitmap images. The SVG output can have hyperlinked text allowing users to quickly navigate to documentation of different syntax elements.
JSyntrax is a Java reimplementation of syntrax project, originally written in Python. We use Apache Batik for SVG rasterization.
The aim of this project is to make syntrax
tool easy to install on any operating system. No software and libraries are required for jsyntrax
besides Java 11.
JSyntrax requires JDK 11 or later.
Download the latest release from GitHub Releases page.
Unzip the archive anywhere, /bin
directory will contain the executable syntrax
file.
The full documentation is available online at the main JSyntrax site.