alles liftm behalve parseseplist
[cc1516.git] / src / parse.dcl
1 definition module parse
2
3 from Data.Either import :: Either
4 from Data.Maybe import :: Maybe
5
6 import lex
7
8 :: ParserOutput :== Either String AST
9
10 :: AST = AST [VarDecl] [FunDecl]
11 :: VarDecl = VarDecl Type String Expr
12 :: Type
13 = TupleType (Type, Type)
14 | ListType Type
15 | IdType String
16 | IntType
17 | BoolType
18 | CharType
19 | VarType
20 :: Expr
21 = VarExpr VarDef
22 | Op2Expr Expr Op2 Expr
23 | Op1Expr Op1 Expr
24 | IntExpr Int
25 | CharExpr Char
26 | BoolExpr Bool
27 | FunExpr FunCall
28 | EmptyListExpr
29 | TupleExpr (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 String [String] FunType [VarDecl] [Stmt]
36 :: FunType = FunType [Type] (Maybe Type)
37 :: FunCall = FunCall String [Expr]
38 :: Stmt
39 = IfStmt Expr [Stmt] [Stmt]
40 | WhileStmt Expr [Stmt]
41 | AssStmt VarDef Expr
42 | FunStmt FunCall
43 | ReturnStmt (Maybe Expr)
44
45 instance toString AST
46
47 parser :: LexerOutput -> ParserOutput