-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAST.hs
69 lines (59 loc) · 2.05 KB
/
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
module AST where
{- Grupo 1
Árvore -}
data SL = Program String [DeclProg] Boolean [Decl] [Inst] Boolean Boolean
deriving Show
data Decl = Atr TypeDecl String Expr
| AtrT TypeDecl String
| AtrS TypeDecl [Expr]
deriving (Show , Eq , Ord)
data DeclProg = AtrProg TypeDecl String
deriving (Show , Eq , Ord)
data TypeDecl = Int | Char | Bool
deriving (Show , Eq , Ord)
data Inst = Assign String Expr
| IfThenElse Boolean [Inst] [Inst]
| For Decl Boolean Expr [Inv] [Inst]
| While Boolean Boolean [Inst]
| Read Expr
| Print Expr
| Return Expr
| Try [Inst] [Inst]
| Throw
deriving (Show , Eq , Ord)
data Inv = Inv Boolean
deriving (Show, Eq, Ord)
data Expr = Const Integer
| Var String
| Add Expr Expr
| Mul Expr Expr
| Div Expr Expr
| Sub Expr Expr
| Same Expr Expr
deriving (Show , Eq , Ord)
data Boolean = Expr Expr
| Greater Expr Expr
| GreaterEqual Expr Expr
| Less Expr Expr
| LessEqual Expr Expr
| And Expr Boolean
| Orl Expr Boolean
| Equal Expr Expr
| Different Expr Expr
| BoolConst Bool
| Implies Expr Boolean
| Not Expr
deriving (Show , Eq , Ord)
data Boolean2 = Expr2 Expr
| Greater2 Expr Expr
| GreaterEqual2 Expr Expr
| Less2 Expr Expr
| LessEqual2 Expr Expr
| And2 Boolean2 Boolean2
| Orl2 Boolean2 Boolean2
| Equal2 Expr Expr
| Different2 Expr Expr
| BoolConst2 Bool
| Implies2 Boolean2 Boolean2
| Not2 Boolean2
deriving (Show , Eq , Ord)