blob: 080b8502cbe855b195de49c01636185e4c01455a (
plain)
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
|
module CC.Source(module CC.Source, module CC.Types) where
import CC.Pretty
import CC.Types
data Program = Program [Decl]
deriving (Show, Read)
data Decl = Def Def -- import?
deriving (Show, Read)
data Def = Function (Maybe Type)
(Name, SourceRange)
[(Name, SourceRange)]
Expr
deriving (Show, Read)
data Type = TFun Type Type
| TInt
deriving (Show, Read)
data Expr = Lam SourceRange [(Name, SourceRange)] Expr
| Call SourceRange Expr Expr
| Int SourceRange Int
| Var SourceRange Name
| Annot SourceRange Expr Type
deriving (Show, Read)
instance Pretty Type where
prettyPrec _ TInt = "Int"
prettyPrec p (TFun a b) =
precParens p 2 (prettyPrec 3 a ++ " -> " ++ prettyPrec 2 b)
instance HasRange Expr where
range (Lam sr _ _) = sr
range (Call sr _ _) = sr
range (Int sr _) = sr
range (Var sr _) = sr
range (Annot sr _ _) = sr
|