module Commander (
TsouTAPL(..)
, processArgs
) where
import System.Console.CmdArgs
data TsouTAPL = Untyped { prgfile :: FilePath
, unprotected :: Bool
}
| Typed { prgfile :: FilePath
, ctxfile :: [FilePath]
, unprotected :: Bool
}
deriving (Show, Data, Typeable)
version = "2.6"
welcomeMsg = "TsouTAPL v" ++ version ++ ", by Thanos Tsouanas <thanos@sians.org>."
processArgs :: IO TsouTAPL
processArgs = cmdArgs welcomeMsg $ map mode [untyped, typed]
untyped = Untyped
{ prgfile = def &= argPos 0 & typ "PROGRAM_FILE"
, unprotected = def &= text "Unsafe mode: no protection from obvious infinite loops."
} &= text "Untyped lambda calculus with unit, booleans and arithmetic."
typed = Typed
{ prgfile = def &= argPos 0 & typ "PROGRAM_FILE"
, ctxfile = def &= explicit & flag "c" & flag "context" & typ "CONTEXT_FILE"
& text "File containing pure context."
, unprotected = def &= text "Unsafe mode: no protection from obvious infinite loops."
} &= text "Typed lambda calculus with unit, booleans, arithmetic and wrong."