---input---
letter = "A" | "B" | "C" | "D" | "E" | "F" | "G"
       | "H" | "I" | "J" | "K" | "L" | "M" | "N"
       | "O" | "P" | "Q" | "R" | "S" | "T" | "U"
       | "V" | "W" | "X" | "Y" | "Z" ;
digit = "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" ;
symbol = "[" | "]" | "{" | "}" | "(" | ")" | "<" | ">"
       | "'" | '"' | "=" | "|" | "." | "," | ";" ;
character = letter | digit | symbol | " " ;

identifier = letter , { letter | digit | " " } ;
terminal = "'" , character , { character } , "'"
         | '"' , character , { character } , '"' ;

special = "?" , any , "?" ;

comment = (* this is a comment "" *) "(*" , any-symbol , "*)" ;
any-symbol = ? any visible character ? ; (* ? ... ? *)

lhs = identifier ;
rhs = identifier
     | terminal
     | comment , rhs
     | rhs , comment
     | "[" , rhs , "]"
     | "{" , rhs , "}"
     | "(" , rhs , ")"
     | rhs , "|" , rhs
     | rhs , "," , rhs ;

rule = lhs , "=" , rhs , ";" | comment ;
grammar = { rule } ;

---tokens---
'letter '     Keyword
'='           Operator
' '           Text
'"A"'         Literal.String.Double
' '           Text
'|'           Punctuation
' '           Text
'"B"'         Literal.String.Double
' '           Text
'|'           Punctuation
' '           Text
'"C"'         Literal.String.Double
' '           Text
'|'           Punctuation
' '           Text
'"D"'         Literal.String.Double
' '           Text
'|'           Punctuation
' '           Text
'"E"'         Literal.String.Double
' '           Text
'|'           Punctuation
' '           Text
'"F"'         Literal.String.Double
' '           Text
'|'           Punctuation
' '           Text
'"G"'         Literal.String.Double
'\n       '   Text
'|'           Punctuation
' '           Text
'"H"'         Literal.String.Double
' '           Text
'|'           Punctuation
' '           Text
'"I"'         Literal.String.Double
' '           Text
'|'           Punctuation
' '           Text
'"J"'         Literal.String.Double
' '           Text
'|'           Punctuation
' '           Text
'"K"'         Literal.String.Double
' '           Text
'|'           Punctuation
' '           Text
'"L"'         Literal.String.Double
' '           Text
'|'           Punctuation
' '           Text
'"M"'         Literal.String.Double
' '           Text
'|'           Punctuation
' '           Text
'"N"'         Literal.String.Double
'\n       '   Text
'|'           Punctuation
' '           Text
'"O"'         Literal.String.Double
' '           Text
'|'           Punctuation
' '           Text
'"P"'         Literal.String.Double
' '           Text
'|'           Punctuation
' '           Text
'"Q"'         Literal.String.Double
' '           Text
'|'           Punctuation
' '           Text
'"R"'         Literal.String.Double
' '           Text
'|'           Punctuation
' '           Text
'"S"'         Literal.String.Double
' '           Text
'|'           Punctuation
' '           Text
'"T"'         Literal.String.Double
' '           Text
'|'           Punctuation
' '           Text
'"U"'         Literal.String.Double
'\n       '   Text
'|'           Punctuation
' '           Text
'"V"'         Literal.String.Double
' '           Text
'|'           Punctuation
' '           Text
'"W"'         Literal.String.Double
' '           Text
'|'           Punctuation
' '           Text
'"X"'         Literal.String.Double
' '           Text
'|'           Punctuation
' '           Text
'"Y"'         Literal.String.Double
' '           Text
'|'           Punctuation
' '           Text
'"Z"'         Literal.String.Double
' '           Text
';'           Punctuation
'\n'          Text

'digit '      Keyword
'='           Operator
' '           Text
'"0"'         Literal.String.Double
' '           Text
'|'           Punctuation
' '           Text
'"1"'         Literal.String.Double
' '           Text
'|'           Punctuation
' '           Text
'"2"'         Literal.String.Double
' '           Text
'|'           Punctuation
' '           Text
'"3"'         Literal.String.Double
' '           Text
'|'           Punctuation
' '           Text
'"4"'         Literal.String.Double
' '           Text
'|'           Punctuation
' '           Text
'"5"'         Literal.String.Double
' '           Text
'|'           Punctuation
' '           Text
'"6"'         Literal.String.Double
' '           Text
'|'           Punctuation
' '           Text
'"7"'         Literal.String.Double
' '           Text
'|'           Punctuation
' '           Text
'"8"'         Literal.String.Double
' '           Text
'|'           Punctuation
' '           Text
'"9"'         Literal.String.Double
' '           Text
';'           Punctuation
'\n'          Text

'symbol '     Keyword
'='           Operator
' '           Text
'"["'         Literal.String.Double
' '           Text
'|'           Punctuation
' '           Text
'"]"'         Literal.String.Double
' '           Text
'|'           Punctuation
' '           Text
'"{"'         Literal.String.Double
' '           Text
'|'           Punctuation
' '           Text
'"}"'         Literal.String.Double
' '           Text
'|'           Punctuation
' '           Text
'"("'         Literal.String.Double
' '           Text
'|'           Punctuation
' '           Text
'")"'         Literal.String.Double
' '           Text
'|'           Punctuation
' '           Text
'"<"'         Literal.String.Double
' '           Text
'|'           Punctuation
' '           Text
'">"'         Literal.String.Double
'\n       '   Text
'|'           Punctuation
' '           Text
'"\'"'        Literal.String.Double
' '           Text
'|'           Punctuation
' '           Text
'\'"\''       Literal.String.Single
' '           Text
'|'           Punctuation
' '           Text
'"="'         Literal.String.Double
' '           Text
'|'           Punctuation
' '           Text
'"|"'         Literal.String.Double
' '           Text
'|'           Punctuation
' '           Text
'"."'         Literal.String.Double
' '           Text
'|'           Punctuation
' '           Text
'","'         Literal.String.Double
' '           Text
'|'           Punctuation
' '           Text
'";"'         Literal.String.Double
' '           Text
';'           Punctuation
'\n'          Text

'character '  Keyword
'='           Operator
' '           Text
'letter '     Keyword
'|'           Punctuation
' '           Text
'digit '      Keyword
'|'           Punctuation
' '           Text
'symbol '     Keyword
'|'           Punctuation
' '           Text
'" "'         Literal.String.Double
' '           Text
';'           Punctuation
'\n\n'        Text

'identifier ' Keyword
'='           Operator
' '           Text
'letter '     Keyword
','           Punctuation
' '           Text
'{'           Punctuation
' '           Text
'letter '     Keyword
'|'           Punctuation
' '           Text
'digit '      Keyword
'|'           Punctuation
' '           Text
'" "'         Literal.String.Double
' '           Text
'}'           Punctuation
' '           Text
';'           Punctuation
'\n'          Text

'terminal '   Keyword
'='           Operator
' '           Text
'"\'"'        Literal.String.Double
' '           Text
','           Punctuation
' '           Text
'character '  Keyword
','           Punctuation
' '           Text
'{'           Punctuation
' '           Text
'character '  Keyword
'}'           Punctuation
' '           Text
','           Punctuation
' '           Text
'"\'"'        Literal.String.Double
'\n         ' Text
'|'           Punctuation
' '           Text
'\'"\''       Literal.String.Single
' '           Text
','           Punctuation
' '           Text
'character '  Keyword
','           Punctuation
' '           Text
'{'           Punctuation
' '           Text
'character '  Keyword
'}'           Punctuation
' '           Text
','           Punctuation
' '           Text
'\'"\''       Literal.String.Single
' '           Text
';'           Punctuation
'\n\n'        Text

'special '    Keyword
'='           Operator
' '           Text
'"?"'         Literal.String.Double
' '           Text
','           Punctuation
' '           Text
'any '        Keyword
','           Punctuation
' '           Text
'"?"'         Literal.String.Double
' '           Text
';'           Punctuation
'\n\n'        Text

'comment '    Keyword
'='           Operator
' '           Text
'(*'          Comment.Multiline
' '           Comment.Multiline
't'           Comment.Multiline
'h'           Comment.Multiline
'i'           Comment.Multiline
's'           Comment.Multiline
' '           Comment.Multiline
'i'           Comment.Multiline
's'           Comment.Multiline
' '           Comment.Multiline
'a'           Comment.Multiline
' '           Comment.Multiline
'c'           Comment.Multiline
'o'           Comment.Multiline
'm'           Comment.Multiline
'm'           Comment.Multiline
'e'           Comment.Multiline
'n'           Comment.Multiline
't'           Comment.Multiline
' '           Comment.Multiline
'"'           Comment.Multiline
'"'           Comment.Multiline
' '           Comment.Multiline
'*)'          Comment.Multiline
' '           Text
'"(*"'        Literal.String.Double
' '           Text
','           Punctuation
' '           Text
'any-symbol ' Keyword
','           Punctuation
' '           Text
'"*)"'        Literal.String.Double
' '           Text
';'           Punctuation
'\n'          Text

'any-symbol ' Keyword
'='           Operator
' '           Text
'? any visible character ?' Name.Entity
' '           Text
';'           Punctuation
' '           Text
'(*'          Comment.Multiline
' '           Comment.Multiline
'?'           Comment.Multiline
' '           Comment.Multiline
'.'           Comment.Multiline
'.'           Comment.Multiline
'.'           Comment.Multiline
' '           Comment.Multiline
'?'           Comment.Multiline
' '           Comment.Multiline
'*)'          Comment.Multiline
'\n\n'        Text

'lhs '        Keyword
'='           Operator
' '           Text
'identifier ' Keyword
';'           Punctuation
'\n'          Text

'rhs '        Keyword
'='           Operator
' '           Text
'identifier'  Keyword
'\n     '     Text
'|'           Punctuation
' '           Text
'terminal'    Keyword
'\n     '     Text
'|'           Punctuation
' '           Text
'comment '    Keyword
','           Punctuation
' '           Text
'rhs'         Keyword
'\n     '     Text
'|'           Punctuation
' '           Text
'rhs '        Keyword
','           Punctuation
' '           Text
'comment'     Keyword
'\n     '     Text
'|'           Punctuation
' '           Text
'"["'         Literal.String.Double
' '           Text
','           Punctuation
' '           Text
'rhs '        Keyword
','           Punctuation
' '           Text
'"]"'         Literal.String.Double
'\n     '     Text
'|'           Punctuation
' '           Text
'"{"'         Literal.String.Double
' '           Text
','           Punctuation
' '           Text
'rhs '        Keyword
','           Punctuation
' '           Text
'"}"'         Literal.String.Double
'\n     '     Text
'|'           Punctuation
' '           Text
'"("'         Literal.String.Double
' '           Text
','           Punctuation
' '           Text
'rhs '        Keyword
','           Punctuation
' '           Text
'")"'         Literal.String.Double
'\n     '     Text
'|'           Punctuation
' '           Text
'rhs '        Keyword
','           Punctuation
' '           Text
'"|"'         Literal.String.Double
' '           Text
','           Punctuation
' '           Text
'rhs'         Keyword
'\n     '     Text
'|'           Punctuation
' '           Text
'rhs '        Keyword
','           Punctuation
' '           Text
'","'         Literal.String.Double
' '           Text
','           Punctuation
' '           Text
'rhs '        Keyword
';'           Punctuation
'\n\n'        Text

'rule '       Keyword
'='           Operator
' '           Text
'lhs '        Keyword
','           Punctuation
' '           Text
'"="'         Literal.String.Double
' '           Text
','           Punctuation
' '           Text
'rhs '        Keyword
','           Punctuation
' '           Text
'";"'         Literal.String.Double
' '           Text
'|'           Punctuation
' '           Text
'comment '    Keyword
';'           Punctuation
'\n'          Text

'grammar '    Keyword
'='           Operator
' '           Text
'{'           Punctuation
' '           Text
'rule '       Keyword
'}'           Punctuation
' '           Text
';'           Punctuation
'\n'          Text
