identity example now almost correctly typed
[cc1516.git] / AST.dcl
1 definition module AST
2
3 from Data.Maybe import :: Maybe
4 from StdOverloaded import class toString, class ==, class zero, class <
5
6 :: Pos = {line :: Int, col :: Int}
7 :: AST = AST [FunDecl]
8 :: VarDecl = VarDecl Pos (Maybe Type) String Expr
9 :: TVar :== String
10 :: Type
11 = TupleType (Type, Type)
12 | ListType Type
13 | IdType TVar
14 | IntType
15 | BoolType
16 | CharType
17 | VoidType
18 | (->>) infixl 7 Type Type
19 :: Expr
20 = VarExpr Pos VarDef
21 | Op2Expr Pos Expr Op2 Expr
22 | Op1Expr Pos Op1 Expr
23 | IntExpr Pos Int
24 | CharExpr Pos Char
25 | BoolExpr Pos Bool
26 | FunExpr Pos String [Expr] [FieldSelector]
27 | EmptyListExpr Pos
28 | TupleExpr Pos (Expr, Expr)
29 :: VarDef = VarDef String [FieldSelector]
30 :: FieldSelector = FieldHd | FieldTl | FieldFst | FieldSnd
31 :: Op1 = UnNegation | UnMinus
32 :: Op2 = BiPlus | BiMinus | BiTimes | BiDivide | BiMod | BiEquals | BiLesser |
33 BiGreater | BiLesserEq | BiGreaterEq | BiUnEqual | BiAnd | BiOr | BiCons
34 :: FunDecl = FunDecl Pos String [String] (Maybe Type) [VarDecl] [Stmt]
35 :: Stmt
36 = IfStmt Expr [Stmt] [Stmt]
37 | WhileStmt Expr [Stmt]
38 | AssStmt VarDef Expr
39 | FunStmt String [Expr]
40 | ReturnStmt (Maybe Expr)
41
42 instance toString Pos
43 instance toString Type
44 instance toString AST
45 instance toString FieldSelector
46 instance toString Op2
47 instance toString Expr
48 instance toString VarDecl
49
50 instance zero Pos
51 instance == Op1
52 instance == Op2
53 instance < Op1
54 instance < Op2
55 instance == Type