aboutsummaryrefslogtreecommitdiff
path: root/LogicParser.icl
diff options
context:
space:
mode:
Diffstat (limited to 'LogicParser.icl')
-rw-r--r--LogicParser.icl16
1 files changed, 11 insertions, 5 deletions
diff --git a/LogicParser.icl b/LogicParser.icl
index 320e2cc..fbf19ef 100644
--- a/LogicParser.icl
+++ b/LogicParser.icl
@@ -26,12 +26,18 @@ module LogicParser
import StdEnv, StdMaybe, ArgEnv, Logic
Start
-| argc < 1 = abort ("Usage: " +++ argv.[0] +++ " -b -nt <string>\n")
-| extended = toString (truthtable (parse argv.[2]))
-| otherwise = toString (simple_truthtable_n [parse argv.[n] \\ n <- [1..argc]])
-//| otherwise = toString ((if extended truthtable simple_truthtable) (parse argv.[1]))
+| isEmpty exprs = abort ("Usage: " +++ argv.[0] +++ " -b -nt [-e] [-html|-latex] <string>\n")
+| otherwise = show outputoption (compute (if extended truthtable_n simple_truthtable_n (map parse exprs)))
where
argc = size argv - 1
argv = getCommandLine
- extended = argv.[1] == "-e"
+
+ exprs = filter (\s . s.[0] <> '-') [argv.[n] \\ n <- [1..argc]]
+
+ extended = hasArg "-e"
+ outputoption
+ | hasArg "-html" = Html
+ | hasArg "-latex" = LaTeX
+ | otherwise = Plain
+ hasArg arg = or [arg == argv.[n] \\ n <- [0..argc]]