-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAbsPascal.hs
More file actions
131 lines (107 loc) · 2.52 KB
/
Copy pathAbsPascal.hs
File metadata and controls
131 lines (107 loc) · 2.52 KB
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
module AbsPascal where
--Identificatore delle variabili
type Ident = String
data Program = Prog Ident [Statement]
deriving (Eq, Show)
--Istruzioni dentro un block
data Statement = StatementBlock [Statement]
| StatementDec Declaration
| StatementAss Assignment
| StatementRexpr RExpr
| StatementCond Condition
| StatementFunc FunDecl
| StatementLoop Loop
deriving (Eq, Show)
--L-expression
data LExpr = LId Ident
| LPt LExpr
| LArr Ident RExpr
deriving (Eq, Show)
--dichiarazione di variabili, costanti, puntatori e array
data Declaration = VarDec Ident Type RExpr
| ConstDec Ident RExpr
| PointerDec Ident Type
| ArrayDec Ident RExpr RExpr Type
deriving (Eq, Show)
--dichiarazione delle funzioni e procedure
data FunDecl = Fun Ident [Parameter] Type [Statement]
| Proc Ident [Parameter] [Statement]
deriving (Eq, Show)
--dichiarazione dei parametri di una funzione/procedura
data Parameter = Param Ident Type
deriving (Eq, Show)
--Dichiarazione degli assegnamenti (semplici, puntatori, array)
data Assignment = AssSimple Ident AssignmentOperator RExpr
| PointerAssSimple Ident AssignmentOperator RExpr
| ArrayAssSimple Ident RExpr AssignmentOperator RExpr
deriving(Eq, Show)
--Dichiarazione degli operatori di assegnamento
data AssignmentOperator = AssEqual
deriving (Eq,Show)
--dichiarazione if/ifElse
data Condition = IfNoElse RExpr Statement
| IfElse RExpr Statement Statement
| IfNoElseBreak RExpr
| IfElseBreak RExpr Statement
| IfNoElseContinue RExpr
| IfElseContinue RExpr Statement
deriving (Eq, Show)
--Dichiarazione dei cicli
data Loop = While RExpr Statement
| For Assignment RExpr Statement
| WhileContinue RExpr
| WhileBreak RExpr
| ForContinue Assignment RExpr
| ForBreak Assignment RExpr
deriving (Eq,Show)
--Valori delle variabili
data RExpr = RInt Int
| RFloat Float
| RBool Bool
| RChar Char
| RString String
| ROpBin RExpr BinaryOperator RExpr
| ROpUn UnaryOperator RExpr
| Par RExpr
| RxLx LExpr
deriving (Eq,Show)
--Dichiarazione degli operatori unari
data UnaryOperator = Not
deriving (Eq,Show)
--Dichiarazione degli operatori binari
data BinaryOperator = Add
| Sub
| Mult
| Mod
| Div
| DivInt
| And
| Or
| LessThan
| GreaterThan
| LessEq
| GreaterEq
| EqComp
| Neq
deriving (Eq,Show)
--Tipi semplici
data Type = SInt
| SChar
| SFloat
| SBool
| SString
| SFunction
| SProcedure
--Tipi costanti
| CInt
| CChar
| CFloat
| CBool
| CString
--tipi accettati dalle funzioni
| FInt
| FChar
| FFloat
| FBool
| FString
deriving (Eq, Show)