-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAst.hs
46 lines (37 loc) · 952 Bytes
/
Ast.hs
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
module Ast where
data Module = Module [Func]
deriving Show
data Func = Func {
name :: String,
visability :: Visability,
args :: [String],
body :: Expr
}
deriving Show
data Visability = Public
| Private
deriving Show
data Expr = BOp Op Expr Expr
| Let String Expr Expr
| Case Expr [PatExpr]
| Call String [Expr]
| Var String
| Lit32 Integer -- using Integer makes some codegen easier
-- (avoiding incidental complexity)
deriving Show
data PatExpr = PatExpr Pattern Expr
deriving Show
data Pattern = Number Integer
| Wildcard
deriving Show
data Op = Add
| Subtract
| Multiply
| Divide
| LessThan
| LessThanEqualTo
| GreaterThan
| GreaterThanEqualTo
| NotEqual
| Equal
deriving Show