Discover assembly output file
This commit is contained in:
parent
9ace3632bc
commit
e5728a0fb4
1 changed files with 13 additions and 6 deletions
|
|
@ -18,13 +18,21 @@ import Mima.Options
|
||||||
import Mima.Parse.Assembly
|
import Mima.Parse.Assembly
|
||||||
|
|
||||||
data Settings = Settings
|
data Settings = Settings
|
||||||
{ infile :: String
|
{ infile :: FilePath
|
||||||
, outfile :: String
|
, outfile :: Maybe FilePath
|
||||||
, discover :: Bool
|
, discover :: Bool
|
||||||
, flagFile :: Maybe FilePath
|
, flagFile :: Maybe FilePath
|
||||||
, symbolFile :: Maybe FilePath
|
, symbolFile :: Maybe FilePath
|
||||||
} deriving (Show)
|
} deriving (Show)
|
||||||
|
|
||||||
|
getOutfile :: Settings -> FilePath
|
||||||
|
getOutfile settings =
|
||||||
|
case outfile settings of
|
||||||
|
Just path -> path
|
||||||
|
Nothing -> discoveredPath
|
||||||
|
where
|
||||||
|
discoveredPath = dropExtension (infile settings) ++ ".mima"
|
||||||
|
|
||||||
getFlagFile :: Settings -> File
|
getFlagFile :: Settings -> File
|
||||||
getFlagFile settings =
|
getFlagFile settings =
|
||||||
case flagFile settings of
|
case flagFile settings of
|
||||||
|
|
@ -52,12 +60,11 @@ settingsParser = Settings
|
||||||
<$> strArgument
|
<$> strArgument
|
||||||
(metavar "INFILE"
|
(metavar "INFILE"
|
||||||
<> help "The .mimasm file to assemble")
|
<> help "The .mimasm file to assemble")
|
||||||
<*> strOption
|
<*> (optional . strOption)
|
||||||
(long "out"
|
(long "out"
|
||||||
<> short 'o'
|
<> short 'o'
|
||||||
<> metavar "OUTFILE"
|
<> metavar "OUTFILE"
|
||||||
<> help "The .mima file to write the assembled result to"
|
<> help "The .mima file to write the assembled result to"
|
||||||
<> value "out.mima"
|
|
||||||
<> showDefault)
|
<> showDefault)
|
||||||
<*> switchWithNo "discover" True
|
<*> switchWithNo "discover" True
|
||||||
"Derive the file names for the .mima-flags and .mima-symbols files from the name of the input file"
|
"Derive the file names for the .mima-flags and .mima-symbols files from the name of the input file"
|
||||||
|
|
@ -105,8 +112,8 @@ main = doRun_ $ do
|
||||||
(state, labels, flags) <- loadFile readAssembly (infile settings)
|
(state, labels, flags) <- loadFile readAssembly (infile settings)
|
||||||
lift $ putStrLn "Parsing successful"
|
lift $ putStrLn "Parsing successful"
|
||||||
|
|
||||||
lift $ putStrLn $ "Writing result to " ++ outfile settings
|
lift $ putStrLn $ "Writing result to " ++ getOutfile settings
|
||||||
saveStateToFile (outfile settings) state
|
saveStateToFile (getOutfile settings) state
|
||||||
|
|
||||||
saveFlags flags settings
|
saveFlags flags settings
|
||||||
saveSymbols labels settings
|
saveSymbols labels settings
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue