railroad_dsl
railroad_dsl copied to clipboard
A small DSL to generate syntax diagrams
A small DSL to generate syntax diagrams using this library.
-
{...}
is a horizontal stack of connected elements -
[...]
is a vertical sequence of connected elements -
<...>
is a choice of multiple options, exactly one of which has to be picked -
"foobar"
is a terminal -
'foobar'
is a non-terminal -
`foobar`
is a comment -
...?
is an optional element -
...*...
is a repeated element -
!
is the empty element
Quotes (and backslashes) can be escaped using backslashes.
For example:
{["CONSTRAINT" "name"]?,
<["PRIMARY" "KEY" <!, "ASC", "DESC"> 'conflict-clause' <!, "AUTOINCREMENT">],
["NOT" "NULL" 'conflict-clause'],
["UNIQUE" 'conflict-clause'],
["CHECK" "(" 'expr' ")"],
["DEFAULT" <'signed-number', 'literal-value', ["(" 'expr' ")"]>],
["COLLATE" "collation-name"],
'foreign-key-clause'>}