-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathTypes.hs
More file actions
60 lines (51 loc) · 1.17 KB
/
Copy pathTypes.hs
File metadata and controls
60 lines (51 loc) · 1.17 KB
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
module Types where
type VarName = String
data Lit
= LitInt Int
| LitBool Bool
| LitNull
| LitString String
deriving (Show, Eq, Read)
data Expr
= ExprLit Lit
| ExprVar VarName
| ExprBinOp BinOp Expr Expr
| ExprNot Expr
| ExprFuncCall VarName [Expr]
| ExprNull
| ExprSome Expr
| ExprMatch Expr Expr Expr
| ExprList [Expr]
| ExprString String
| ExprIndex Expr Expr
deriving (Show, Eq, Read)
data BinOp
= Add | Sub | Mul | Div--算术
| Eq | Neq | Lt | Leq--比较
| And | Or--逻辑
deriving (Show, Eq, Read)
data Stmt
= Assign VarName Expr
|Return Expr
| If Expr [Stmt] [Stmt]
| While Expr [Stmt]
| Input VarName
| Print Expr
| Block [Stmt]
| AssignIndex Expr Expr Expr
deriving (Show, Eq, Read)
data Type = TypeInt | TypeBool |TypeOptional Type
deriving (Show, Eq, Read)
type Param = (VarName, Type)
data Func = Func
{ funcName :: VarName
, funcParams :: [Param]
, funcReturnType :: Type
, funcBody :: [Stmt]
}
deriving (Show, Eq, Read)
data Program = Program
{ progFuncs :: [Func]
, progMain :: [Stmt]
}
deriving (Show, Eq, Read)