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