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