cli, cps interpreter, stack vm, closure-conversion, fixes, tests, LOL
build / build (push) Successful in 7m49s
build / build (push) Successful in 7m49s
This commit is contained in:
+25
-5
@@ -1,6 +1,7 @@
|
||||
{-# LANGUAGE NoFieldSelectors #-}
|
||||
module Gyehoek.Options
|
||||
( Options(..)
|
||||
, Runtime(..)
|
||||
, parser
|
||||
)
|
||||
where
|
||||
@@ -12,13 +13,18 @@ import System.FilePath
|
||||
import qualified Data.HashSet as HS
|
||||
import Control.Lens hiding (argument)
|
||||
import GHC.Generics (Generic)
|
||||
import Data.Foldable
|
||||
|
||||
|
||||
data Runtime = Stackify | Wasm | CPS
|
||||
deriving (Show, Generic)
|
||||
|
||||
data Options = MkOptions
|
||||
{ dumpCPS :: Bool
|
||||
{ dumpClosed :: Bool
|
||||
, dumpCPS :: Bool
|
||||
, dumpParsed :: Bool
|
||||
, dumpStackified :: Bool
|
||||
, stackify :: Bool
|
||||
, runtime :: Maybe Runtime
|
||||
, inspectWasm :: Bool
|
||||
, output :: FilePath
|
||||
, sourceFile :: FilePath
|
||||
@@ -48,18 +54,32 @@ parseOutput = strOption
|
||||
<> value "-"
|
||||
)
|
||||
|
||||
parseRuntime = option rdr . fold $
|
||||
[ long "runtime"
|
||||
, short 'R'
|
||||
, value Nothing
|
||||
]
|
||||
where
|
||||
rdr = maybeReader \case
|
||||
"stackify" -> Just (Just Stackify)
|
||||
"wasm" -> Just (Just Wasm)
|
||||
"cps" -> Just (Just CPS)
|
||||
"none" -> Just Nothing
|
||||
_ -> Nothing
|
||||
|
||||
parseDumpClosed = switch (long "dump-closed")
|
||||
parseDumpCPS = switch (long "dump-cps")
|
||||
parseDumpStackified = switch (long "dump-stackified")
|
||||
parseStackify = switch (long "stackify")
|
||||
parseDumpParsed = switch (long "dump-parsed")
|
||||
parseInspectWasm = switch $ long "inspect-wasm" <> short 'p'
|
||||
|
||||
parser :: Parser Options
|
||||
parser = MkOptions
|
||||
<$> parseDumpCPS
|
||||
<$> parseDumpClosed
|
||||
<*> parseDumpCPS
|
||||
<*> parseDumpParsed
|
||||
<*> parseDumpStackified
|
||||
<*> parseStackify
|
||||
<*> parseRuntime
|
||||
<*> parseInspectWasm
|
||||
<*> parseOutput
|
||||
<*> argument str (metavar "FILE")
|
||||
|
||||
Reference in New Issue
Block a user