, Railroad Diagram Generator,
Railroad
Diagram
Generator

v1.24.557   Jan 9, 2013
RR written by
Gunther Rademacher
grd@gmx.net

Built with Sausalito - 100% XQuery
100% XQuery
Download diagram
SVG  single XHTML page with
embedded SVG graphics
PNG  zip file containing HTML
and linked PNG images
Download

Welcome to Railroad Diagram Generator!

This is a tool for creating syntax diagrams, also known as railroad diagrams, from context-free grammars specified in EBNF. Syntax diagrams have been used for decades now, so the concept is well-known, and some tools for diagram generation are in existence. This one has a focus on web orientation, so its features are

  • usage of the W3C's EBNF notation,
  • web-scraping of grammars from W3C specifications,
  • online editing of grammars,
  • diagram presentation in SVG,
  • and it was completely written in web languages (XQuery, XHTML, CSS, JavaScript).
Due to the use of SVG, a browser capable of handling inline SVG is required. However this applies to most modern browsers.

Notation

For the original description of the EBNF notation as it is used here, please refer to "A.1.1 Notation" in the XQuery recommendation. The XML recommendation contains a similar section, "6 Notation". Below is a self-describing grammar for the EBNF notation.

Grammar ::= Production*
Production ::= NCName '::=' ( Choice | Link )
NCName ::= [http://www.w3.org/TR/xml-names/#NT-NCName]
Choice ::= SequenceOrDifference ( '|' SequenceOrDifference )*
SequenceOrDifference ::= (Item ( '-' Item | Item* ))?
Item ::= Primary ( '?' | '*' | '+' )?
Primary ::= NCName | StringLiteral | CharCode | CharClass | '(' Choice ')'
StringLiteral ::= '"' [^"]* '"' | "'" [^']* "'" /* ws: explicit */
CharCode ::= '#x' [0-9a-fA-F]+ /* ws: explicit */
CharClass ::= '[' '^'? ( Char | CharCode | CharRange | CharCodeRange )+ ']' /* ws: explicit */
Char ::= [http://www.w3.org/TR/xml#NT-Char]
CharRange ::= Char '-' ( Char - ']' ) /* ws: explicit */
CharCodeRange ::= CharCode '-' CharCode /* ws: explicit */
Link ::= '[' URL ']'
URL ::= [^#x5D:/?#]+ '://' [^#x5D#]+ ('#' NCName)? /* ws: explicit */
Whitespace ::= S | Comment
S ::= #x9 | #xA | #xD | #x20
Comment ::= '/*' ( [^*] | '*'+ [^*/] )* '*'* '*/' /* ws: explicit */

For viewing railroad diagrams of this very grammar, you could either

  • select "EBNF Notation" from the "Get Grammar" tab, or
  • copy and paste the above grammar to the "Edit Grammar" tab
and then proceed to the "View Diagram" tab. Or just click here for a shortcut.

From this website:

EBNF Notation

From W3C specifications:

Extensible Markup Language (XML) 1.0http://www.w3.org/TR/xml/
Namespaces in XML 1.0http://www.w3.org/TR/xml-names/
XML Path Language (XPath) 2.0http://www.w3.org/TR/xpath20/
XML Path Language (XPath) 3.0http://www.w3.org/TR/xpath-30/
XQuery 1.0: An XML Query Language (Second Edition)http://www.w3.org/TR/xquery/
XQuery 3.0: An XML Query Languagehttp://www.w3.org/TR/xquery-30/
XQuery Update Facility 1.0http://www.w3.org/TR/xquery-update-10/
XQuery Update Facility 3.0http://www.w3.org/TR/xquery-update-30/
XQuery Scripting Extension 1.0http://www.w3.org/TR/xquery-sx-10/
SPARQL Query Language for RDFhttp://www.w3.org/TR/rdf-sparql-query/
otherenter URI below
 
URI 
Clear Save  Load

The following options may affect the application's performance.

Suppress EBNF display
  Usually the corresponding EBNF will be shown next to generated diagrams. If this option is checked, the EBNF display will be suppressed.
 
Use external parser
  When checked, parsing will be delegated to an external, Java coded parser servlet. Otherwise the built-in, XQuery-coded parser will be used. Turning on this option may provide a performance advantage, as the XQuery-coded parser suffers from some Zorba performance problems. It may become obsolete with future Zorba versions providing more optimizations. See this post on the Zorba-users mailing list.
 
Show precomputed SVG for standard grammars
  When this option is used, the server will return precomputed SVG syntax diagrams for the standard URIs shown on the "Get Grammar" tab. When unchecked, syntax diagrams will always be computed on the fly. This was also introduced for performance reasons, in order to faster present standard graphics. The option may become unnecessary with future Zorba versions, providing more optimizations. Note that precomputed SVG will be returned in the server request upon leaving the "Get Grammar" tab for "Edit" or "View". In all other cases, SVG will be recomputed anyway, where necessary.

For seeing response times of server requests doing web scraping or SVG rendering, hover your mouse slightly left of the bold "Railroad" at the top right of this page.