-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAbsMCalc.hs
84 lines (66 loc) · 1.72 KB
/
AbsMCalc.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
module AbsMCalc where
-- Haskell module generated by the BNF converter
newtype Ident = Ident String deriving (Eq, Ord, Show, Read)
data Program = Prog [Entity]
deriving (Eq, Ord, Show, Read)
data Entity
= Ettstm Stm | Ettfundec FunctionDeclare | Ettfundef Function
deriving (Eq, Ord, Show, Read)
data FunctionDeclare = Fundec Type Ident [FuncDeclarg]
deriving (Eq, Ord, Show, Read)
data Function = Fundef Type Ident [FuncDefarg] [Stm]
deriving (Eq, Ord, Show, Read)
data FuncDeclarg
= Vartypearg Type
| Varnamearg Type Ident
| Varinitarg Type Ident Exp
deriving (Eq, Ord, Show, Read)
data FuncDefarg = Vararg Type Ident | Varargass Type Ident Exp
deriving (Eq, Ord, Show, Read)
data VarDecl = DeclVar Ident | DeclVarInit Ident Exp
deriving (Eq, Ord, Show, Read)
data Stm
= SDecl Type [VarDecl]
| SExp Exp
| SBlock [Stm]
| SIf Exp Stm
| SIfElse Exp Stm Stm
| SWhile Exp Stm
| SReturn Exp
| SRetnul
| SPrint Exp
deriving (Eq, Ord, Show, Read)
data Exp
= EAssign Ident Exp
| Edisjunc Exp Exp
| Econjunc Exp Exp
| Eeq Exp Exp
| Eineq Exp Exp
| Ecmplt Exp Exp
| Ecmpgt Exp Exp
| Ecmplet Exp Exp
| Ecmpget Exp Exp
| EAdd Exp Exp
| ESub Exp Exp
| EMul Exp Exp
| EDiv Exp Exp
| ENeg Exp
| Epos Exp
| Epreinc Ident
| Epredec Ident
| Epostinc Ident
| Epostdec Ident
| Efunc Ident
| Efuncpar Ident [Exp]
| Evar Ident
| Econst Constant
deriving (Eq, Ord, Show, Read)
data Constant
= EString String
| Eint Integer
| EDouble Double
| Ebool_false
| Ebool_true
deriving (Eq, Ord, Show, Read)
data Type = TInt | TBool | TDouble | TString | TVoid
deriving (Eq, Ord, Show, Read)