From: Mart Lubbers Date: Mon, 11 Mar 2019 09:28:52 +0000 (+0100) Subject: updates' X-Git-Url: https://git.martlubbers.net/?a=commitdiff_plain;h=8b4342bc6b15fc09c81e19003ee03a52d8744054;p=minfp.git updates' git pus --- diff --git a/Makefile b/Makefile index c0b5828..d532f0d 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ CLM?=clm -CLMFLAGS?=-b +CLMFLAGS?=-nr CLMLIBS?=-IL Platform all: main diff --git a/main.icl b/main.icl index 9f9fd86..136c0e1 100644 --- a/main.icl +++ b/main.icl @@ -32,20 +32,21 @@ opts = , Option ['g'] ["gen"] (NoArg (const MGen)) "Up to and including generation" ] -Start :: *World -> Either [String] [String] +Start :: *World -> *World Start w # ([argv0:args], w) = getCommandLine w # (mode, positionals, errs) = getOpt Permute opts args # mode = foldl (o) id mode MInterpret - | not (errs =: []) = Left [e +++ "\n"\\e<-errs] - | not (positionals =: []) = Left ["Positional arguments not allowed"] +// | not (errs =: []) = Left [e +++ "\n"\\e<-errs] +// | not (positionals =: []) = die ["Positional arguments not allowed"] w # (io, w) = stdio w # (cs, io) = chars io - # (_, w) = fclose io w - = case mode of + # mstr = case mode of MHelp = Left [usageInfo ("Usage: " +++ argv0 +++ " [opts]\n") opts] MLex = map (\x->toString x +++ "\n") <$> lex cs MParse = map (\x->toString x +++ "\n") <$> (lex cs >>= parse) MType = (\(e, x)->["type: ",toString x, "\n", toString e]) <$> (lex cs >>= parse >>= check) MInterpret = (\x->[toString x]) <$> (lex cs >>= parse >>= check >>= int o fst) MGen = lex cs >>= parse >>= check >>= gen o fst + = setReturnCode (either (const 1) (const 0) mstr) + (snd (fclose (foldr fwrites io (either id id mstr)) w)) diff --git a/tests/preamble.mfp b/tests/preamble.mfp index 8c01e96..120f93f 100644 --- a/tests/preamble.mfp +++ b/tests/preamble.mfp @@ -6,4 +6,4 @@ $ ifxr 0 x y = x y; + ifxl 6 = code add; if = code if; fac i = if (i == 0) 1 (i * fac (i - 1)); -start = fac; +start = fac 10;