@@ -553,30 +553,32 @@ main = do
553
553
parserInfoModifiers
554
554
for_ (localOptions options) mainWithOptions
555
555
556
+ {- | Use the parsed 'KoreExecOptions' to set up output and logging, then
557
+ dispatch the requested command.
558
+ -}
556
559
mainWithOptions :: KoreExecOptions -> IO ()
557
560
mainWithOptions execOptions = do
558
- let KoreExecOptions
559
- { koreLogOptions
560
- , koreSolverOptions
561
- , bugReportOption
562
- }
563
- = execOptions
561
+ let KoreExecOptions { koreSolverOptions, bugReportOption, outputFileName } = execOptions
564
562
ensureSmtPreludeExists koreSolverOptions
565
563
exitCode <-
566
564
withBugReport Main. exeName bugReportOption $ \ tmpDir -> do
567
- writeOptionsAndKoreFiles tmpDir execOptions
568
- go <* warnIfLowProductivity
565
+ let execOptions' = execOptions {
566
+ outputFileName = Just (tmpDir </> " result.kore" ) }
567
+ writeOptionsAndKoreFiles tmpDir execOptions'
568
+ e <- mainDispatch execOptions' <* warnIfLowProductivity
569
569
& handle handleWithConfiguration
570
570
& handle handleSomeException
571
571
& runKoreLog tmpDir koreLogOptions
572
+ case outputFileName of
573
+ Nothing -> readFile (tmpDir </> " result.kore" ) >>= putStr
574
+ Just fileName -> copyFile (tmpDir </> " result.kore" ) fileName
575
+ return e
572
576
let KoreExecOptions { rtsStatistics } = execOptions
573
577
for_ rtsStatistics $ \ filePath ->
574
578
writeStats filePath =<< getStats
575
579
exitWith exitCode
576
580
where
577
- KoreExecOptions { koreProveOptions } = execOptions
578
- KoreExecOptions { koreSearchOptions } = execOptions
579
- KoreExecOptions { koreMergeOptions } = execOptions
581
+ KoreExecOptions { koreLogOptions } = execOptions
580
582
581
583
handleSomeException :: SomeException -> Main ExitCode
582
584
handleSomeException someException = do
@@ -594,21 +596,27 @@ mainWithOptions execOptions = do
594
596
(" // Last configuration:\n " <> unparse lastConfiguration)
595
597
throwM someException
596
598
597
- go :: Main ExitCode
598
- go
599
- | Just proveOptions@ KoreProveOptions {bmc} <- koreProveOptions =
600
- if bmc
601
- then koreBmc execOptions proveOptions
602
- else koreProve execOptions proveOptions
599
+ {- | Dispatch the requested command, for example 'koreProve' or 'koreRun'.
600
+ -}
601
+ mainDispatch :: KoreExecOptions -> Main ExitCode
602
+ mainDispatch execOptions
603
+ | Just proveOptions@ KoreProveOptions {bmc} <- koreProveOptions =
604
+ if bmc
605
+ then koreBmc execOptions proveOptions
606
+ else koreProve execOptions proveOptions
603
607
604
- | Just searchOptions <- koreSearchOptions =
605
- koreSearch execOptions searchOptions
608
+ | Just searchOptions <- koreSearchOptions =
609
+ koreSearch execOptions searchOptions
606
610
607
- | Just mergeOptions <- koreMergeOptions =
608
- koreMerge execOptions mergeOptions
611
+ | Just mergeOptions <- koreMergeOptions =
612
+ koreMerge execOptions mergeOptions
609
613
610
- | otherwise =
611
- koreRun execOptions
614
+ | otherwise =
615
+ koreRun execOptions
616
+ where
617
+ KoreExecOptions { koreProveOptions } = execOptions
618
+ KoreExecOptions { koreSearchOptions } = execOptions
619
+ KoreExecOptions { koreMergeOptions } = execOptions
612
620
613
621
koreSearch :: KoreExecOptions -> KoreSearchOptions -> Main ExitCode
614
622
koreSearch execOptions searchOptions = do
0 commit comments