Merge branch 'master' of github.com:dopefishh/cc1516
[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 :: Type
10 = TupleType (Type, Type)
11 | ListType Type
12 | IdType String
13 | IntType
14 | BoolType
15 | CharType
16 | VoidType
17 | (->>) infixl 7 Type Type
18 :: Expr
19 = VarExpr Pos VarDef
20 | Op2Expr Pos Expr Op2 Expr
21 | Op1Expr Pos Op1 Expr
22 | IntExpr Pos Int
23 | CharExpr Pos Char
24 | BoolExpr Pos Bool
25 | FunExpr Pos String [Expr] [FieldSelector]
26 | EmptyListExpr Pos
27 | TupleExpr Pos (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 Pos String [String] (Maybe Type) [VarDecl] [Stmt]
34 :: Stmt
35 = IfStmt Expr [Stmt] [Stmt]
36 | WhileStmt Expr [Stmt]
37 | AssStmt VarDef Expr
38 | FunStmt String [Expr]
39 | ReturnStmt (Maybe Expr)
40
41 instance toString Pos
42 instance toString Type
43 instance toString AST
44
45 instance zero Pos
46 instance == Op1
47 instance == Op2
48 instance < Op1
49 instance < Op2