-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgrammar.lark
47 lines (39 loc) · 1.41 KB
/
grammar.lark
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
start: (command ";")*
?command: term
| CNAME ":" func_ty -> bind
?term: "lambda" CNAME (":" func_ty)? "." term -> abs
| "let" CNAME "=" term "in" term -> let
| "if" term "then" term "else" term -> if_stmt
| app_term
| "(" term ("," term)+ ")" -> tuple
?app_term: "succ" aterm -> succ
| "pred" aterm -> pred
| "iszero" aterm -> iszero
| aterm
| app_term aterm -> app
?aterm: "(" term ")"
| "true" -> true
| "false" -> false
| INT -> nat
| CNAME -> var
?func_ty: type "->" func_ty -> arr_ty
| type
?type: "Nat" -> nat_ty
| "Bool" -> bool_ty
| ID_TY -> id_ty
| "(" func_ty ")"
| "(" func_ty ("," func_ty)+ ")" -> tuple_ty
ID_TY: UCASE_LETTER ("_"|LETTER|DIGIT)*
%import common.WS
%import common.C_COMMENT
%import common.CPP_COMMENT
%import common.CNAME
%import common.UCASE_LETTER
%import common.DIGIT
%import common.LETTER
%import common.INT
%import common.SH_COMMENT
%ignore WS
%ignore C_COMMENT
%ignore CPP_COMMENT
%ignore SH_COMMENT