Skip to content

Grammar railroad diagram #3

@mingodad

Description

@mingodad

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 Mon Dec 12, 2022, 11:54 (UTC+01) by antlr_4-to-w3c v0.62 which is Copyright (c) 2011-2022 by Gunther Rademacher <grd@gmx.net> */

start    ::= program EOF
program  ::= packageDecl? useDecl* ( decl | clause )*
packageDecl
         ::= 'Package' NAME atoms? '!'
useDecl  ::= 'Use' NAME atoms? '!'
decl     ::= 'Decl' atom descrBlock? boundsBlock* constraintsBlock? '.'
descrBlock
         ::= 'descr' atoms
boundsBlock
         ::= 'bound' '[' term ( ',' term )* ']'
constraintsBlock
         ::= 'inclusion' atoms
clause   ::= atom ( ':-' clauseBody )? '.'
clauseBody
         ::= literalOrFml ( ',' literalOrFml )* ( '|>' transform )?
transform
         ::= ( 'do' term | letStmt ) ( ',' letStmt )*
letStmt  ::= 'let' VARIABLE '=' term
literalOrFml
         ::= ( term ( '=' | '!=' | '<' | '<=' ) | '!' )? term
term     ::= VARIABLE
           | CONSTANT
           | NUMBER
           | STRING
           | NAME '(' ( term ( ',' term )* )? ')'
           | '[' ( ( ( term ',' )* | term ':' ( term ',' term ':' )* ) term )? ']'
           | '{' ( term ':' term ( ',' term ':' term )* )? '}'
atom     ::= term
atoms    ::= '[' ( atom ( ',' atom )* )? ']'
_        ::= WHITESPACE
           | COMMENT
          /* ws: definition */

<?TOKENS?>

WHITESPACE
         ::= [ #x9#xD#xA#xC]+
COMMENT  ::= '#' [^#xA]*
NEWLINE  ::= #xA
LETTER   ::= [A-Za-z]
DIGIT    ::= [0-9]
NUMBER   ::= '-'? DIGIT+
VARIABLE_START
         ::= [A-Z]
VARIABLE_CHAR
         ::= LETTER
           | DIGIT
VARIABLE ::= '_'
           | VARIABLE_START VARIABLE_CHAR*
NAME_CHAR
         ::= LETTER
           | DIGIT
           | ':'
           | '_'
NAME     ::= ':'? [a-z] ( '.'? NAME_CHAR )*
CONSTANT_CHAR
         ::= LETTER
           | DIGIT
           | '.'
           | '-'
           | '_'
           | '~'
           | '%'
CONSTANT ::= ( '/' CONSTANT_CHAR+ )+
STRING   ::= SHORT_STRING
           | LONG_STRING
SHORT_STRING
         ::= "'" ( STRING_ESCAPE_SEQ | [^\'#xd#xa#xc] )* "'"
           | '"' ( STRING_ESCAPE_SEQ | [^\"#xd#xa#xc] )* '"'
LONG_STRING
         ::= '`' LONG_STRING_ITEM* '`'
LONG_STRING_ITEM
         ::= LONG_STRING_CHAR
           | STRING_ESCAPE_SEQ
LONG_STRING_CHAR
         ::= [^-]
STRING_ESCAPE_SEQ
         ::= '\' ( . | NEWLINE )
EOF      ::= $

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions