-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgrammar.txt
29 lines (21 loc) · 957 Bytes
/
grammar.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
program ::= statement EOF | statement EOL program
statement ::= funcsig | funcbody
funcsig ::= SYMBOL "::" funcsigtype
funcsigtype ::= functypes "->" functype | functype
functypes ::= functype | functype functypes
functype ::= type | type "=" arg
type ::= "[" type "]" | tupletype | SYMBOL
tupletype ::= "(" type "," ")" | "(" type "," tupletypes ")"
tupletypes ::= type | type "," tupletypes
funcbody ::= SYMBOL params "=" expr
params ::= param params | λ
param ::= SYMBOL | pattern
pattern ::= literal | "(" expr ")"
expr ::= literal | SYMBOL | funccall | "(" expr ")" | expr BINOP expr
funccall ::= SYMBOL args
args ::= arg | arg args
arg ::= literal | SYMBOL | "(" expr ")"
literal ::= NATLIT | BOOLLIT | listlit | tuplelit
listlit ::= "[" listitems "]" | "[" "]"
listitems ::= expr | expr "," listitems
tuplelit ::= "(" expr "," ")" | "(" expr "," listitems ")"