add input and output commands parsing and call compilation

This commit is contained in:
Aivean
2018-04-28 16:47:23 -07:00
parent 7422dc8551
commit 8d3a452902
2 changed files with 34 additions and 33 deletions
+15 -23
View File
@@ -3,31 +3,23 @@ module Wasm.WasmParser where
import Options.Applicative
import Data.Semigroup ((<>))
data WasmFileFormat = WasmText | WasmBinary | WasmScript deriving (Read, Show)
instance Read WasmFileFormat where
readsPrec _ ("WAT":xs) = [ (WasmText, xs) ]
readsPrec _ ("WAST":xs) = [ (WasmScript, xs) ]
readsPrec _ ("WASM":xs) = [ (WasmBinary, xs) ]
--data WasmFileFormat = WasmText | WasmBinary | WasmScript deriving (Read, Show)
--
--instance Read WasmFileFormat where
-- readsPrec _ ("WAT":xs) = [ (WasmText, xs) ]
-- readsPrec _ ("WAST":xs) = [ (WasmScript, xs) ]
-- readsPrec _ ("WASM":xs) = [ (WasmBinary, xs) ]
data WasmParser = WasmParser
{ hello :: String
, quiet :: Bool
, enthusiasm :: Int }
{ output :: Maybe String
, input :: String }
sample :: Parser WasmParser
sample = WasmParser
<$> strOption
( long "hello"
<> metavar "TARGET"
<> help "Target for the greeting" )
<*> switch
( long "quiet"
<> short 'q'
<> help "Whether to be quiet" )
<*> option auto
( long "enthusiasm"
<> help "How enthusiastically to greet"
<> showDefault
<> value 1
<> metavar "INT" )
<$> option (maybeReader (Just . Just))
( long "output"
<> short 'o'
<> metavar "OUTPUT_FILE"
<> help "Output filename"
<> value Nothing )
<*> argument str (metavar "INPUT_FILE")