-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathAbsGrammar.hs
84 lines (65 loc) · 1.7 KB
/
AbsGrammar.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 AbsGrammar where
-- Haskell module generated by the BNF converter
newtype Ident = Ident String deriving (Eq, Ord, Show, Read)
data Program = Program [Stmt]
deriving (Eq, Ord, Show, Read)
data Block = Block [Stmt]
deriving (Eq, Ord, Show, Read)
data Stmt
= BStmt Block
| Decl Type Item
| Ass Ident Expr
| Ret Expr
| VRet
| Cond Expr Block
| CondElse Expr Block Block
| While Expr Stmt
| For Ident Expr Expr Stmt
| ForIn Ident Expr Stmt
| Print Expr
| SFormat String [Expr]
| SExp Expr
| FnDef Ident [Arg] Type Block
| ListPush Ident Expr
deriving (Eq, Ord, Show, Read)
data Item = NoInit Ident | Init Ident Expr
deriving (Eq, Ord, Show, Read)
data Arg = Arg Type Ident | RefArg Type Ident
deriving (Eq, Ord, Show, Read)
data Type
= TInt
| TBool
| TString
| Void
| TList Type
| AnonFun Type [TypeOrRef]
deriving (Eq, Ord, Show, Read)
data TypeOrRef = TypeOrRefType Type | TypeOrRefRef Type
deriving (Eq, Ord, Show, Read)
data Expr
= ListLength Expr
| ListAt Expr Expr
| ELambda [Ident] [Arg] Type Block
| ELitInt Integer
| EVar Ident
| ELitTrue
| ELitFalse
| EEmptyList Type
| EString String
| EApp Expr [ExprOrRef]
| 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 ExprOrRef = ERExpr Expr | ERRef Ident
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)