-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathAbsDeclaration.hs
131 lines (118 loc) · 1.94 KB
/
AbsDeclaration.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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
module AbsDeclaration where
-- Haskell module generated by the BNF converter
newtype Ident =
Ident String
deriving (Eq, Ord, Read)
instance Show Ident where
show (Ident str) = "'" ++ str ++ "'"
data Program =
Program [TopDef]
deriving (Eq, Ord, Show, Read)
data TopDef
= FnDef Type
Ident
[Arg]
Block
| GlobDecl Type
[Item]
| GlobFinDecl Type
[Item]
deriving (Eq, Ord, Show, Read)
data Arg =
Arg Type
Ident
deriving (Eq, Ord, Show, Read)
data Block =
Block [Stmt]
deriving (Eq, Ord, Show, Read)
data Stmt
= Empty
| BStmt Block
| Decl Type
[Item]
| DeclFinal Type
[Item]
| Ass Ident
Expr
| Incr Ident
| Decr Ident
| Ret Expr
| VRet
| Cond Expr
Stmt
| CondElse Expr
Stmt
Stmt
| While Expr
Stmt
| SExp Expr
| FnInDef Type
Ident
[Arg]
Block
| ConstFor Type
Ident
Expr
Expr
Stmt
| Break
| Continue
| Print Expr
deriving (Eq, Ord, Show, Read)
data Item
= NoInit Ident
| Init Ident
Expr
deriving (Eq, Ord, Show, Read)
data Type
= Int
| Str
| Bool
| Void
| FuncType [Type]
Type
deriving (Eq, Ord, Show, Read)
data Expr
= EVar Ident
| ELitInt Integer
| ELitTrue
| ELitFalse
| EApp Ident
[Expr]
| EString String
| ELambda [Arg]
Type
Block
| Neg Expr
| Not Expr
| EMul Expr
MulOp
Expr
| EAdd Expr
AddOp
Expr
| ERel Expr
RelOp
Expr
| EAnd Expr
Expr
| EOr Expr
Expr
deriving (Eq, Ord, Show, Read)
data AddOp
= Plus
| Minus
deriving (Eq, Ord, Show, Read)
data MulOp
= Times
| Div
| Mod
deriving (Eq, Ord, Show, Read)
data RelOp
= LTH
| LE
| GTH
| GE
| EQU
| NE
deriving (Eq, Ord, Show, Read)