aboutsummaryrefslogtreecommitdiff
path: root/ast/CC/Typed.hs
diff options
context:
space:
mode:
Diffstat (limited to 'ast/CC/Typed.hs')
-rw-r--r--ast/CC/Typed.hs35
1 files changed, 35 insertions, 0 deletions
diff --git a/ast/CC/Typed.hs b/ast/CC/Typed.hs
new file mode 100644
index 0000000..b11067f
--- /dev/null
+++ b/ast/CC/Typed.hs
@@ -0,0 +1,35 @@
+module CC.Typed(
+ module CC.Typed,
+ module CC.Types
+) where
+
+import CC.Types
+
+
+data ProgramT = ProgramT [DeclT]
+ deriving (Show, Read)
+
+data DeclT = DefT DefT -- import?
+ deriving (Show, Read)
+
+data DefT = FunctionT TypeT Name [Name] ExprT
+ deriving (Show, Read)
+
+data TypeT = TFunT TypeT TypeT
+ | TIntT
+ | TyVar Int
+ deriving (Show, Read)
+
+data ExprT = CallT TypeT ExprT ExprT
+ | IntT Int
+ | VarT Occ
+ deriving (Show, Read)
+
+-- | Occurrence of a variable
+data Occ = Occ Name TypeT
+ deriving (Show, Read)
+
+exprType :: ExprT -> TypeT
+exprType (CallT typ _ _) = typ
+exprType (IntT _) = TIntT
+exprType (VarT (Occ _ typ)) = typ