-
Notifications
You must be signed in to change notification settings - Fork 0
/
AbsSwifty.hs
90 lines (69 loc) · 1.9 KB
/
AbsSwifty.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
module AbsSwifty where
-- Haskell module generated by the BNF converter
newtype Ident = Ident String deriving (Eq, Ord, Show, Read)
data Program = Prog [Stmt]
deriving (Eq, Ord, Show, Read)
data Decl
= D_Fun Ident [PDecl] Type Stmt
| D_Proc Ident [PDecl] Stmt
| D_Var Ident Expr
| D_Str Ident
| D_MVar Ident [Ident] Expr
deriving (Eq, Ord, Show, Read)
data PDecl = P_Decl Ident Type
deriving (Eq, Ord, Show, Read)
data Block = B_Block [Stmt]
deriving (Eq, Ord, Show, Read)
data Acc = A_Iden Ident | A_Arr Acc ArraySub | A_Str Acc StructSub
deriving (Eq, Ord, Show, Read)
data Stmt
= S_Block Block
| S_Decl Decl
| S_Assign Acc Expr
| S_MAss Acc [Acc] Tuple
| S_While Expr Stmt
| S_For Ident Acc Stmt
| S_If Expr Stmt
| S_IfE Expr Block Stmt
| S_Return Expr
| S_Print Expr
| S_Expr FCall
deriving (Eq, Ord, Show, Read)
data FCall = Fun_Call Ident [Expr]
deriving (Eq, Ord, Show, Read)
data ArraySub = Arr_Sub Expr
deriving (Eq, Ord, Show, Read)
data Array = Arr [Expr]
deriving (Eq, Ord, Show, Read)
data Tuple = Tup Expr [Expr]
deriving (Eq, Ord, Show, Read)
data StructSub = Str_Sub Ident
deriving (Eq, Ord, Show, Read)
data Expr
= E_Or Expr Expr
| E_And Expr Expr
| E_Eq Expr Expr
| E_Neq Expr Expr
| E_Lt Expr Expr
| E_Gt Expr Expr
| E_Lte Expr Expr
| E_Gte Expr Expr
| E_Add Expr Expr
| E_Subt Expr Expr
| E_Mult Expr Expr
| E_Div Expr Expr
| E_Min Expr
| E_Neg Expr
| E_ArrI Array
| E_ArrI2 Expr Expr
| E_TupI Tuple
| E_ArrS Acc ArraySub
| E_StrS Acc StructSub
| E_FuncCall FCall
| E_Const Constant
| E_VarName Ident
deriving (Eq, Ord, Show, Read)
data Constant = False_Const | True_Const | Integer_Const Integer
deriving (Eq, Ord, Show, Read)
data Type = T_Int | T_Bool | T_Arr Type | T_Tup [Type] | T_Ref Type
deriving (Eq, Ord, Show, Read)