mirror of
https://git.cs.ou.nl/joshua.moerman/mealy-decompose.git
synced 2025-04-29 17:57:44 +02:00
actually using the command line options
This commit is contained in:
parent
dbecd98e18
commit
e938befa20
4 changed files with 16 additions and 12 deletions
|
@ -1,6 +1,7 @@
|
|||
module DecomposeInput where
|
||||
|
||||
import Bisimulation (bisimulation2)
|
||||
import CommonOptions
|
||||
import Data.Partition (Block (..), numBlocks)
|
||||
import Data.UnionFind (empty, equate, equivalent)
|
||||
import DotParser (readDotFile)
|
||||
|
@ -15,6 +16,7 @@ import Data.Set qualified as Set
|
|||
import Data.Text qualified as T
|
||||
import Options.Applicative
|
||||
import System.Exit (exitFailure, exitSuccess)
|
||||
import System.FilePath ((</>))
|
||||
|
||||
newtype DecomposeInputOptions = DecomposeInputOptions
|
||||
{ filename :: FilePath
|
||||
|
@ -52,12 +54,12 @@ interleavingComposition alphs m =
|
|||
-- [dotFile] -> putStrLn ("reading " <> dotFile) >> run dotFile
|
||||
-- _ -> putStrLn "Please provide a dot file"
|
||||
-- where
|
||||
mainDecomposeInput :: DecomposeInputOptions -> IO ()
|
||||
mainDecomposeInput DecomposeInputOptions{..} = do
|
||||
mainDecomposeInput :: DecomposeInputOptions -> CommonOptions -> IO ()
|
||||
mainDecomposeInput DecomposeInputOptions{..} CommonOptions{..} = do
|
||||
let
|
||||
dotFile = filename
|
||||
report s = appendFile "results/log.txt" (dotFile <> "\t" <> s <> "\n")
|
||||
witness s = appendFile "results/witnesses.txt" (dotFile <> "\n" <> s <> "\n\n")
|
||||
report s = appendFile (logDirectory </> "hs-decompose-input.txt") (dotFile <> "\t" <> s <> "\n")
|
||||
witness s = appendFile (resultsDirectory </> "hs-decompose-input-witnesses.txt") (dotFile <> "\n" <> s <> "\n\n")
|
||||
|
||||
report "START-INPUT-DECOMP"
|
||||
model <- readDotFile dotFile
|
||||
|
|
|
@ -24,6 +24,7 @@ import Data.Text.IO qualified as T
|
|||
import Data.Text.Lazy.IO qualified as TL
|
||||
import Data.Tuple (swap)
|
||||
import Options.Applicative
|
||||
import System.FilePath ((</>))
|
||||
|
||||
data DecomposeOutputOptions = DecomposeOutputOptions
|
||||
{ filename :: FilePath
|
||||
|
@ -31,7 +32,7 @@ data DecomposeOutputOptions = DecomposeOutputOptions
|
|||
}
|
||||
deriving Show
|
||||
|
||||
decomposeOutputOptionsParser :: _
|
||||
decomposeOutputOptionsParser :: Parser DecomposeOutputOptions
|
||||
decomposeOutputOptionsParser =
|
||||
DecomposeOutputOptions
|
||||
<$> argument str (help "Filename to read (dot format)" <> metavar "FILE")
|
||||
|
@ -41,7 +42,7 @@ decomposeOutputOptionsParser =
|
|||
mainDecomposeOutput :: DecomposeOutputOptions -> CommonOptions -> IO ()
|
||||
mainDecomposeOutput DecomposeOutputOptions{..} CommonOptions{..} = do
|
||||
let
|
||||
report s = appendFile "results/log.txt" (filename <> "\t" <> s <> "\n")
|
||||
report s = appendFile (logDirectory </> "hs-decompose-output-hs.txt") (filename <> "\t" <> s <> "\n")
|
||||
|
||||
-- READING INPUT
|
||||
----------------
|
||||
|
@ -134,7 +135,7 @@ mainDecomposeOutput DecomposeOutputOptions{..} CommonOptions{..} = do
|
|||
content = T.unlines . fmap T.unwords . toBlocks $ p
|
||||
|
||||
putStrLn $ " Output (partition) in file " <> filename'
|
||||
T.writeFile ("results/" <> filename') content
|
||||
T.writeFile (resultsDirectory </> filename') content
|
||||
|
||||
do
|
||||
let
|
||||
|
@ -166,12 +167,12 @@ mainDecomposeOutput DecomposeOutputOptions{..} CommonOptions{..} = do
|
|||
content2 = toString . mealyToDot name $ result
|
||||
|
||||
putStrLn $ " Output (reduced machine) in file " <> filename1
|
||||
TL.writeFile ("results/" <> filename1) content1
|
||||
TL.writeFile (resultsDirectory </> filename1) content1
|
||||
|
||||
putStrLn $ " Dead inputs = " <> show (Set.size deadInputs)
|
||||
|
||||
putStrLn $ " Output (reduced machine) in file " <> filename2
|
||||
TL.writeFile ("results/" <> filename2) content2
|
||||
TL.writeFile (resultsDirectory </> filename2) content2
|
||||
|
||||
mapM_ processComponent projmapN
|
||||
|
||||
|
|
|
@ -15,13 +15,13 @@ main = do
|
|||
Options{..} <- execParser opts
|
||||
|
||||
-- setup some logging facilities
|
||||
createDirectoryIfMissing True "log"
|
||||
createDirectoryIfMissing True "results"
|
||||
createDirectoryIfMissing True (logDirectory commonOptions)
|
||||
createDirectoryIfMissing True (resultsDirectory commonOptions)
|
||||
|
||||
-- dispatch to actual functionality, based on the command provided
|
||||
case optCommand of
|
||||
DecomposeOutput options -> mainDecomposeOutput options commonOptions
|
||||
DecomposeInput options -> mainDecomposeInput options
|
||||
DecomposeInput options -> mainDecomposeInput options commonOptions
|
||||
|
||||
data Options = Options
|
||||
{ optCommand :: Command
|
||||
|
|
|
@ -44,6 +44,7 @@ executable mealy-decompose-main
|
|||
main-is: Main.hs
|
||||
build-depends:
|
||||
directory,
|
||||
filepath,
|
||||
mealy-decompose,
|
||||
optparse-applicative
|
||||
other-modules:
|
||||
|
|
Loading…
Add table
Reference in a new issue