-
Notifications
You must be signed in to change notification settings - Fork 0
/
grammar_ebnf.txt
36 lines (30 loc) · 1.43 KB
/
grammar_ebnf.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
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" ;
digit = "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" ;
symbol = "[" | "]" | "{" | "}" | "(" | ")" | "<" | ">"
| "+" | "-" | "*" | "/" | "%" | "&" | "|" | "^"
| "=" | "#" | "@" | "_" | "~" | "`" | ":" | ";"
| "?" | "." | "," | "!" ;
whitespace = " " | "\t" | "\n" ;
whitespace_sequence = { whitespace } ;
escape_code = "n" | "t" | "\\" | "'" | '"' ;
escape_sequence = "\\", escape_code ;
character = letter | digit | symbol | whitespace | escape_sequence;
character1 = character | '"' ;
character2 = character | "'" ;
identifier = letter , { letter | digit | "_" } ;
terminal = "'" , character1 , { character1 } , "'"
| '"' , character2 , { character2 } , '"' ;
lhs = [ whitespace_sequence ] , identifier , [ whitespace_sequence ] ;
term = identifier | terminal | "[", rhs, "]" | "{", rhs, "}" | "(", rhs, ")" ;
spaced_term = [ whitespace_sequence ], term, [ whitespace_sequence ] ;
clause = spaced_term , { "," , spaced_term } ;
rhs = clause , { "|" , clause } ;
rule = lhs , "=" , rhs , ";" ;
grammar = { rule } , [ whitespace_sequence ] ;