Grammar Documentation
Grammar Reference
Generated May 6, 2026 · 18 rules · BNF · Generated by DevDiagrams

<syntax>

A complete BNF syntax definition consists of one or more rule definitions.
<syntax>         ::= <rule> | <rule> <syntax>
<rule> <rule> <syntax>

<rule>

A rule definition consists of optional leading whitespace, a rule name
enclosed in angle brackets, the ::= operator, and an expression
terminated by a line ending.
<rule>           ::= <opt-whitespace> "<" <rule-name> ">" <opt-whitespace> "::=" <opt-whitespace> <expression> <line-end>
<opt-whitespace> "<" <rule-name> ">" <opt-whitespace> "::=" <opt-whitespace> <expression> <line-end>

<opt-whitespace>

Optional whitespace is zero or more space characters.
<opt-whitespace> ::= " " <opt-whitespace> | ""
" " <opt-whitespace>

<expression>

An expression is one or more lists separated by the | alternation operator.
<expression>     ::= <list> | <list> <opt-whitespace> "|" <opt-whitespace> <expression>
<list> <list> <opt-whitespace> "|" <opt-whitespace> <expression>

<line-end>

A line ending is optional whitespace followed by an end-of-line marker.
Multiple consecutive line endings are also permitted.
<line-end>       ::= <opt-whitespace> <EOL> | <line-end> <line-end>
<opt-whitespace> <EOL> <line-end> <line-end>

<list>

A list is one or more terms in sequence, separated by optional whitespace.
<list>           ::= <term> | <term> <opt-whitespace> <list>
<term> <term> <opt-whitespace> <list>

<term>

A term is either a quoted string literal or a rule name reference
enclosed in angle brackets.
<term>           ::= <literal> | "<" <rule-name> ">"
<literal> "<" <rule-name> ">"

<literal>

A literal is a quoted string, using either double or single quotes.
<literal>        ::= '"' <text1> '"' | "'" <text2> "'"
'"' <text1> '"' "'" <text2> "'"

<text1>

Text inside double quotes — zero or more characters that may include
single quotes but not double quotes.
<text1>          ::= "" | <character1> <text1>
<character1> <text1>

<text2>

Text inside single quotes — zero or more characters that may include
double quotes but not single quotes.
<text2>          ::= "" | <character2> <text2>
<character2> <text2>

<character>

A character is a letter, digit, or symbol.
<character>      ::= <letter> | <digit> | <symbol>
<letter> <digit> <symbol>

<letter>

A letter is any uppercase or lowercase ASCII letter.
<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" | "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"
"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" "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"
"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""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>

A digit is any ASCII decimal digit 0 through 9.
<digit>          ::= "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9"
"0" "1" "2" "3" "4" "5" "6" "7" "8" "9"
"0""1""2""3""4""5""6""7""8""9"

<symbol>

A symbol is any printable ASCII character that is not a letter or digit.
<symbol>         ::= "|" | " " | "!" | "#" | "$" | "%" | "&" | "(" | ")" | "*" | "+" | "," | "-" | "." | "/" | ":" | ";" | ">" | "=" | "<" | "?" | "@" | "[" | "\" | "]" | "^" | "_" | "`" | "{" | "}" | "~"
"|" " " "!" "#" "$" "%" "&" "(" ")" "*" "+" "," "-" "." "/" ":" ";" ">" "=" "<" "?" "@" "[" "\" "]" "^" "_" "`" "{" "}" "~"
"|"" ""!""#""$""%""&""("")""*""+"",""-"".""/"":"";"">""=""<""?""@""[""\""]""^""_""`""{""}""~"

<character1>

A character inside double quotes — any character plus single quote.
<character1>     ::= <character> | "'"
<character> "'"

<character2>

A character inside single quotes — any character plus double quote.
<character2>     ::= <character> | '"'
<character> '"'

<rule-name>

A rule name begins with a letter and may be followed by any number
of rule name characters.
<rule-name>      ::= <letter> | <rule-name> <rule-char>
<letter> <rule-name> <rule-char>

<rule-char>

A rule name character is a letter, digit, or hyphen.
<rule-char>      ::= <letter> | <digit> | "-"
<letter> <digit> "-"