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