blob: d2748036b2d0867fb25a01b6d8d5b94c6ae87ba4 (
plain) (
blame)
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
|
-- vim: et ts=2 sw=2 ai:
module SPL.Syntax
where
type Name = String
data Program = Program
{ funs :: [Function]
, vars :: [Variable]
}
deriving (Show)
data Function = Function
{ fname :: Name
, ftype :: Maybe Type
, fargs :: [Name]
, fvars :: [Variable]
, fcode :: Statement
}
deriving (Show)
data Variable = Variable
{ vname :: Name
, vtype :: Maybe Type
, vval :: Expression
}
deriving (Show)
data Type
= TInt
| TBool
| TChar
| TList Type
| TTuple Type Type
| TArrow [Type] Type
deriving (Show)
data Statement
= If Expression Statement (Maybe Statement)
| While Expression Statement
| Assign Name Expression
| Eval Expression
| Return (Maybe Expression)
| Seq Statement Statement
deriving (Show)
data Expression
= Field Name Field
| Op2 Expression Op2 Expression
| Op1 Op1 Expression
| Literal Literal
| FunCall Name [Expression]
| Tuple Expression Expression
deriving (Show)
data Field
= Hd
| Tl
| Fst
| Snd
deriving (Show)
data Op2
= Add
| Sub
| Mul
| Div
| Mod
| Eq
| Lt
| Gt
| Le
| Ge
| Ne
| And
| Or
| Cons
deriving (Show)
data Op1
= Not
| Neg
deriving (Show)
data Literal
= LInt Int
| LChar Char
| LBool Bool
| LNil
deriving (Show)
|