X-Git-Url: https://git.martlubbers.net/?a=blobdiff_plain;f=spl.icl;h=383b84e6371cf9c0dde2e0ba01a364738ff87284;hb=978dc486bf8c83cf9cad0925e3128574639656e0;hp=b5738ee23d7ed3465334febe3cc1cc8b275ccb8e;hpb=29d164f53e029e8133e05b599241eb6c14d7fe47;p=cc1516.git diff --git a/spl.icl b/spl.icl index b5738ee..383b84e 100644 --- a/spl.icl +++ b/spl.icl @@ -34,6 +34,16 @@ from yard import :: Error, instance toString Error derive gPrint TokenValue +preamble :: AST -> AST +preamble (AST fd) = AST (pre ++ fd) + where + pre = [ + FunDecl zero "1printstr" ["x"] Nothing [] [ + IfStmt (FunExpr zero "isEmpty" [VarExpr zero (VarDef "x" [])] []) + [] + [FunStmt "1printchar" [VarExpr zero (VarDef "x" [FieldHd])] [] + ,FunStmt "1printstr" [VarExpr zero (VarDef "x" [FieldTl])] []]]] + Start :: *World -> *World Start w # (args, w) = parseArgs w @@ -70,7 +80,7 @@ Start w (Right parseOut) # stdin = if (not args.parse) stdin ( stdin <<< "//PARSER\n" <<< toString parseOut <<< "//PARSER\n") - = case sem parseOut of + = case sem (preamble parseOut) of (Left e) = snd $ fclose (stdin <<< join "\n" (map toString e) <<< "\n") w (Right ast) # stdin = if (not args.sem) stdin (stdin