c272 / iro4cli

An open-source rewrite of Iro, a grammar generator, supporting automatic VSCode & Atom extension generation.
GNU General Public License v3.0
35 stars 5 forks source link

Grammar railroad diagram #16

Open mingodad opened 1 year ago

mingodad commented 1 year ago

Using some online tools like https://www.bottlecaps.de/rr/ui and https://www.bottlecaps.de/convert/ we can have a nice navigable railroad diagram.

Copy and paste the EBNF shown bellow on https://www.bottlecaps.de/rr/ui on the tab Edit Grammar the click on the tab View Diagram to see/download a navigable railroad diagram.

/* converted on Wed May 24, 2023, 09:27 (UTC+02) by antlr_4-to-w3c v0.64 which is Copyright (c) 2011-2023 by Gunther Rademacher <grd@gmx.net> */

compileUnit
         ::= block* EOF
block    ::= statement
           | sys_set
statement
         ::= attribute
           | set
           | include
attribute
         ::= IDENTIFIER definition
sys_set  ::= IDENTIFIER '[]'? '{' statement* '}'
set      ::= IDENTIFIER? '[]'? ':' typed_set
typed_set
         ::= IDENTIFIER ( '{' statement* '}' | statement+ ';' )
include  ::= ':' IDENTIFIER '"' IDENTIFIER '"' ';'
definition
         ::= '[]'? ( '=' | '\=' ) ( definition_ident | HEX_VALUE | regex | constant_ref | array ) ';'?
definition_ident
         ::= '"'? IDENTIFIER '"'?
array    ::= IDENTIFIER ( ',' IDENTIFIER )+
regex    ::= REGEX
constant_ref
         ::= '$' '$' '{' IDENTIFIER '}'
_        ::= COMMENT
           | WS
           | ENDL
          /* ws: definition */

<?TOKENS?>

REGEX    ::= '(' ( [^()#xa#xd] | '\(' | '\)' | REGEX )* ')' ( '|' | '?' | '*' | '+' )* REGEX?
ESCAPED_BRACKET
         ::= '\('
           | '\)'
IDENTIFIER
         ::= [A-Za-z0-9_.#x2D]+
HEX_VALUE
         ::= '#' [0-9A-Za-z]+
COMMENT? ::= '#' .* #xA
WS       ::= [ #xd#x9]+
ENDL     ::= #xA
UNKNOWN_SYMBOL
         ::= .
EOF      ::= $