curry gotcha
[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 | FuncType Type
19 | (->>) infixl 7 Type Type
20 :: Expr
21 = VarExpr Pos VarDef
22 | Op2Expr Pos Expr Op2 Expr
23 | Op1Expr Pos Op1 Expr
24 | IntExpr Pos Int
25 | CharExpr Pos Char
26 | BoolExpr Pos Bool
27 | FunExpr Pos String [Expr] [FieldSelector]
28 | EmptyListExpr Pos
29 | TupleExpr Pos (Expr, Expr)
30 | LambdaExpr Pos [String] Expr
31 :: VarDef = VarDef String [FieldSelector]
32 :: FieldSelector = FieldHd | FieldTl | FieldFst | FieldSnd
33 :: Op1 = UnNegation | UnMinus
34 :: Op2 = BiPlus | BiMinus | BiTimes | BiDivide | BiMod | BiEquals | BiLesser |
35 BiGreater | BiLesserEq | BiGreaterEq | BiUnEqual | BiAnd | BiOr | BiCons
36 :: FunDecl = FunDecl Pos String [String] (Maybe Type) [VarDecl] [Stmt]
37 :: Stmt
38 = IfStmt Expr [Stmt] [Stmt]
39 | WhileStmt Expr [Stmt]
40 | AssStmt VarDef Expr
41 | FunStmt String [Expr] [FieldSelector]
42 | ReturnStmt (Maybe Expr)
43
44 instance toString Pos
45 instance toString Type
46 instance toString AST
47 instance toString FieldSelector
48 instance toString Op2
49 instance toString Expr
50 instance toString VarDecl
51 instance toString FunDecl
52
53 instance zero Pos
54 instance == Op1
55 instance == Op2
56 instance < Op1
57 instance < Op2
58 instance == Type