X-Git-Url: https://git.martlubbers.net/?a=blobdiff_plain;f=parse.dcl;h=ad7edea3ad3fc20ce9645f38767015333544cfe5;hb=a8348a333a567e5a469d1e5f8ec6c3dafc051c91;hp=281c80451da52735801366035ebc4938985f3d9a;hpb=6b3981fb80952fe2c510b6f9b849adb0dff77d2c;p=cc1516.git diff --git a/parse.dcl b/parse.dcl index 281c804..ad7edea 100644 --- a/parse.dcl +++ b/parse.dcl @@ -4,45 +4,9 @@ from Data.Either import :: Either from Data.Maybe import :: Maybe from StdString import class toString -import lex +from lex import :: LexerOutput, :: Error, :: Token, :: TokenValue, :: Pos +from AST import :: AST :: ParserOutput :== Either Error AST -:: AST = AST [VarDecl] [FunDecl] -:: VarDecl = VarDecl Type String Expr -:: Type - = TupleType (Type, Type) - | ListType Type - | IdType String - | IntType - | BoolType - | CharType - | VarType -:: Expr - = VarExpr VarDef - | Op2Expr Expr Op2 Expr - | Op1Expr Op1 Expr - | IntExpr Int - | CharExpr Char - | BoolExpr Bool - | FunExpr FunCall - | EmptyListExpr - | 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 -:: 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 - -parser :: LexerOutput -> ParserOutput +parser :: [Token] -> ParserOutput