-
Notifications
You must be signed in to change notification settings - Fork 0
/
Eggsembly.bnf
72 lines (62 loc) · 3.41 KB
/
Eggsembly.bnf
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
// BNF description of Eggsembly syntax
// Still up for change, though
<syntax> ::= <optionalWs> <line> | <syntax> <endline> <syntax>
<line> ::= <keyword>
| <push>
| <hatch>
| <str> <optionalWs> "as" <optionalWs> <str>
| "build" <ws> <id> <optionalWs> "{" <endline> <syntax> "}"
| "repeat_" <woru> <optionalWs> "{" <endline> <syntax> "}"
| "loop_" <torf> <optionalWs> "{" <endline> <syntax> "}"
| "if_" <torf> <optionalWs> "{" <endline> <syntax> "}"
| <var>
| <optionalWs>
<endline> ::= <optionalWs> <EOL> | <endline> <endline>
<torf> ::= "true" | "false"
<woru> ::= "while" | "until"
<optionalWs> ::= " " <optionalWs> | ""
<ws> ::= " " <ws> | " "
<id> ::= <alunder> | <id> <alnumunder>
<func> ::= <id> | <func> "." <func>
<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> ::= "|" | " " | "!" | "#" | "$" | "%" | "&" | "("
| ")" | "*" | "+" | "," | "-" | "." | "/" | ":"
| ";" | ">" | "=" | "<" | "?" | "@" | "[" |"\\"
| "]" | "^" | "_" | "`" | "{" | "}" | "~"
<alnum> ::= <letter> | <digit>
<alunder> ::= <letter> | "_"
<alnumunder> ::= <alnum> | "_"
<any> ::= <letter> | <digit> | <symbol>
//<anychrs> ::= <any> | <anychrs> <any>
<strchrs1> ::= <any> | "'" | '\"'
<strchrs2> ::= <any> | '"' | "\'"
<string1> ::= <any> | <strchrs1> <any>
<string2> ::= <any> | <strchrs2> <any>
<num> ::= <num> <digit> | <digit>
<float> ::= <num> "." | "." <num> | <num> "." <num>
<keyword> ::= "axe" | "chicken" | "add" | "fox" | "rooster" | "compare" | "pick" | "peck" | "fr" | "bbq"
<str> ::= '"' <string1> '"' | "'" <string2> "'"
<val> ::= <str> | <mathexpr>
<push> ::= "push" <ws> <val>
<hatch> ::= "hatch" <ws> <func>
<mathexpr> ::= <mathexpr> <optionalWs> "+" <optionalWs> <mathexpr>
| <mathexpr> <optionalWs> "-" <optionalWs> <mathexpr>
| <mathexpr> <optionalWs> "*" <optionalWs> <mathexpr>
| <mathexpr> <optionalWs> "/" <optionalWs> <mathexpr>
| <mathexpr> <optionalWs> "\\" <optionalWs> <mathexpr>
| "(" <optionalWs> <mathexpr> <optionalWs> ")"
| <mathexpr> <optionalWs> "(" <optionalWs> <mathexpr> <optionalWs> ")"
| <float>
| <num>
| <id>
<var> ::= <id> <optionalWs> "[" <optionalWs> <num> <optionalWs> "]" <optionalWs> "=" <optionalWs> <val>
| <id> <optionalWs> "[" <optionalWs> <num> <optionalWs> "]" <optionalWs> "=" <optionalWs> "Top"
| <id> <optionalWs> "[" <optionalWs> <num> <optionalWs> "]"
| <id> <optionalWs> "=" <optionalWs> <val>
| <id> <optionalWs> "=" <optionalWs> "Top"
| "const" <ws> <id> <optionalWs> "=" <optionalWs> <val>
| <id>