-
Notifications
You must be signed in to change notification settings - Fork 1
/
bnf
37 lines (21 loc) · 831 Bytes
/
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
program -> form* EOF
form -> (expression | assignment)
assignment -> "let" IDENT "=" expression
expression -> "if" logic_or "then" expression (else expression)?
| "fn" "(" params? ")" "->" expression
| block
| logic_or
params -> IDENT ("," IDENT)*
block -> "do" form* "done" ";"
logic_or -> logic_and ("or" logic_and)*
logic_and -> equality ("and" equality)*
equality -> comparison (("==" | "!=") comparison)*
comparison -> addition (("<" | ">" | "<=" | ">=") addition)*
addition -> multiplication (("+" | "-") multiplication)*
multiplication -> unary (("*" | "/") unary)*
unary -> ("!" | "-") unary | call
call -> primary ("(" args? ")")*
args -> expression ("," expression)*
primary -> NUMBER | STRING | IDENT
| "true" | "false" | "nil"
| "(" expression ")"