X-Git-Url: https://git.martlubbers.net/?a=blobdiff_plain;f=src%2Fparse.dcl;h=281c80451da52735801366035ebc4938985f3d9a;hb=f5231ebadae1ac54e25dbf5819debb3ab625826d;hp=a5bc93a6e89221b1135a3854d010edfe381201cc;hpb=ff0b269598ad277346c81db9d9bc86b4c244e1e2;p=cc1516.git diff --git a/src/parse.dcl b/src/parse.dcl index a5bc93a..281c804 100644 --- a/src/parse.dcl +++ b/src/parse.dcl @@ -2,43 +2,46 @@ definition module parse from Data.Either import :: Either from Data.Maybe import :: Maybe +from StdString import class toString import lex -:: ParserOutput :== Either String AST +:: ParserOutput :== Either Error AST :: AST = AST [VarDecl] [FunDecl] -:: VarDecl = VarDecl String Type Expr +:: VarDecl = VarDecl Type String Expr :: Type - = TupleType Type Type + = TupleType (Type, Type) | ListType Type | IdType String | IntType | BoolType | CharType | VarType - :: Expr - = VarExpr String (Maybe FieldSelector) - | Op2Expr Expr Op2 Expr //TODO, iets met associativiteit wat niet weet hoe + = VarExpr VarDef + | Op2Expr Expr Op2 Expr | Op1Expr Op1 Expr | IntExpr Int | CharExpr Char | BoolExpr Bool - | FunExpr String [Expr] + | FunExpr FunCall | EmptyListExpr - | TupleExpr Expr Expr - + | TupleExpr (Expr, Expr) +:: VarDef = VarDef String [FieldSelector] :: FieldSelector = FieldHd | FieldTl | FieldFst | FieldSnd :: Op1 = UnNegation | UnMinus :: Op2 = BiPlus | BiMinus | BiTimes | BiDivide | BiMod | BiEquals | BiLesser | BiGreater | BiLesserEq | BiGreaterEq | BiUnEqual | BiAnd | BiOr | BiCons - -//TODO - -:: FunDecl = FunDecl String [String] FunType [VarDecl] [Stmt] -:: FunType = Stub -:: Stmt = Stubbel +:: FunDecl = FunDecl String [String] (Maybe FunType) [VarDecl] [Stmt] +:: FunType = FunType [Type] (Maybe Type) +:: FunCall = FunCall String [Expr] +:: Stmt + = IfStmt Expr [Stmt] [Stmt] + | WhileStmt Expr [Stmt] + | AssStmt VarDef Expr + | FunStmt FunCall + | ReturnStmt (Maybe Expr) instance toString AST