Basic Let functionality
[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 :: VarDef = VarDef String [FieldSelector]
31 :: FieldSelector = FieldHd | FieldTl | FieldFst | FieldSnd
32 :: Op1 = UnNegation | UnMinus
33 :: Op2 = BiPlus | BiMinus | BiTimes | BiDivide | BiMod | BiEquals | BiLesser |
34 BiGreater | BiLesserEq | BiGreaterEq | BiUnEqual | BiAnd | BiOr | BiCons
35 :: FunDecl = FunDecl Pos String [String] (Maybe Type) [VarDecl] [Stmt]
36 :: Stmt
37 = IfStmt Expr [Stmt] [Stmt]
38 | WhileStmt Expr [Stmt]
39 | AssStmt VarDef Expr
40 | FunStmt String [Expr] [FieldSelector]
41 | ReturnStmt (Maybe Expr)
42
43 instance toString Pos
44 instance toString Type
45 instance toString AST
46 instance toString FieldSelector
47 instance toString Op2
48 instance toString Expr
49 instance toString VarDecl
50
51 instance zero Pos
52 instance == Op1
53 instance == Op2
54 instance < Op1
55 instance < Op2
56 instance == Type