This commit is contained in:
44
app/Gyehoek/Options.hs
Normal file
44
app/Gyehoek/Options.hs
Normal file
@@ -0,0 +1,44 @@
|
||||
{-# LANGUAGE NoFieldSelectors #-}
|
||||
module Gyehoek.Options
|
||||
( Options(..)
|
||||
, parser
|
||||
)
|
||||
where
|
||||
|
||||
import System.IO (Handle)
|
||||
import Data.HashSet (HashSet)
|
||||
import Options.Applicative
|
||||
import qualified Data.HashSet as HS
|
||||
|
||||
|
||||
data Options = MkOptions
|
||||
{ -- dumpANF :: Maybe FilePath
|
||||
-- , dumpQBE :: Maybe FilePath
|
||||
output :: Maybe FilePath
|
||||
, sourceFiles :: HashSet FilePath
|
||||
}
|
||||
deriving (Show)
|
||||
|
||||
-- parseDumpQBE =
|
||||
-- optional $ strOption
|
||||
-- ( long "dump-qbe"
|
||||
-- <> metavar "FILE"
|
||||
-- )
|
||||
|
||||
-- parseDumpANF =
|
||||
-- optional $ strOption
|
||||
-- ( long "dump-anf"
|
||||
-- <> metavar "FILE"
|
||||
-- )
|
||||
|
||||
parseOutput =
|
||||
optional $ strOption
|
||||
( long "output"
|
||||
<> short 'o'
|
||||
<> metavar "FILE"
|
||||
)
|
||||
|
||||
parser :: Parser Options
|
||||
parser = MkOptions
|
||||
<$> parseOutput
|
||||
<*> (HS.fromList <$> some (argument str (metavar "FILES")))
|
||||
18
app/Main.hs
18
app/Main.hs
@@ -1,17 +1,25 @@
|
||||
{-# LANGUAGE PatternSynonyms #-}
|
||||
{-# LANGUAGE ViewPatterns #-}
|
||||
{-# LANGUAGE BlockArguments #-}
|
||||
{-# LANGUAGE OverloadedLists #-}
|
||||
module Main
|
||||
(main)
|
||||
where
|
||||
|
||||
import qualified Gyehoek.ANF.Syntax as ANF
|
||||
import Gyehoek.QBE (render)
|
||||
import Gyehoek.Options
|
||||
import qualified Data.Text.IO as TIO
|
||||
import Prelude hiding ((.),id)
|
||||
import Control.Category
|
||||
import Options.Applicative
|
||||
|
||||
|
||||
main :: IO ()
|
||||
main = TIO.putStrLn . render $ ANF.expr
|
||||
main = driver =<< execParser opts
|
||||
where
|
||||
opts = info (helper <*> parser)
|
||||
( fullDesc
|
||||
)
|
||||
|
||||
|
||||
|
||||
driver :: Options -> IO ()
|
||||
driver opts = do
|
||||
print opts
|
||||
|
||||
Reference in New Issue
Block a user