Skip to content

Commit 4c7c1db

Browse files
committed
updated code so that it uses new options type
1 parent c4e388d commit 4c7c1db

File tree

2 files changed

+22
-71
lines changed

2 files changed

+22
-71
lines changed

kore/app/parser/Main.hs

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -103,21 +103,23 @@ main = handleTop $ do
103103
$ toVerifiedDefinition indexedModules
104104
else putDoc (debug parsedDefinition)
105105

106-
let KoreParserOptions { patternFileName } = koreParserOptions
107-
unless (null patternFileName) $ do
108-
parsedPattern <- mainPatternParse patternFileName
109-
when willVerify $ do
110-
let KoreParserOptions { mainModuleName } = koreParserOptions
111-
indexedModule <-
112-
lookupMainModule
113-
(ModuleName mainModuleName)
114-
indexedModules
115-
& lift
116-
_ <- mainPatternVerify indexedModule parsedPattern
117-
return ()
118-
let KoreParserOptions { willPrintPattern } = koreParserOptions
119-
when willPrintPattern $
120-
lift $ putDoc (debug parsedPattern)
106+
let KoreParserOptions { patternOpt } = koreParserOptions
107+
case patternOpt of
108+
Nothing -> pure ()
109+
Just PatternOptions {patternFileName, mainModuleName} -> do
110+
parsedPattern <- mainPatternParse patternFileName
111+
when willVerify $ do
112+
indexedModule <-
113+
lookupMainModule
114+
(ModuleName mainModuleName)
115+
indexedModules
116+
& lift
117+
_ <- mainPatternVerify indexedModule parsedPattern
118+
return ()
119+
let KoreParserOptions { willPrintPattern } =
120+
koreParserOptions
121+
when willPrintPattern $
122+
lift $ putDoc (debug parsedPattern)
121123

122124
-- | IO action that parses a kore definition from a filename and prints timing
123125
-- information.

kore/src/Kore/OptionsParser.hs

Lines changed: 5 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ License : NCSA
66

77
module Kore.OptionsParser
88
( enableDisableFlag
9+
, PatternOptions (..)
910
, KoreParserOptions (..)
1011
, commandLineParser
1112
) where
@@ -57,7 +58,7 @@ data PatternOptions = PatternOptions
5758
}
5859

5960
-- | Main options record
60-
data KoreParserOptions' = KoreParserOptions'
61+
data KoreParserOptions = KoreParserOptions
6162
{ fileName :: !FilePath
6263
-- ^ Name for a file containing a definition to parse and verify
6364
, patternOpt :: !(Maybe PatternOptions)
@@ -72,21 +73,10 @@ data KoreParserOptions' = KoreParserOptions'
7273
-- ^ Option to print in applicative Kore syntax
7374
}
7475

75-
76-
data KoreParserOptions = KoreParserOptions
77-
{ fileName :: !FilePath
78-
, patternFileName :: !FilePath
79-
, mainModuleName :: !Text
80-
, willPrintDefinition :: !Bool
81-
, willPrintPattern :: !Bool
82-
, willVerify :: !Bool
83-
, appKore :: !Bool
84-
}
85-
8676
-- | Command Line Argument Parser
87-
commandLineParser' :: Parser KoreParserOptions'
88-
commandLineParser' =
89-
KoreParserOptions'
77+
commandLineParser :: Parser KoreParserOptions
78+
commandLineParser =
79+
KoreParserOptions
9080
<$> argument str
9181
( metavar "FILE"
9282
<> help "Kore source file to parse [and verify]" )
@@ -120,44 +110,3 @@ commandLineParser' =
120110
( "printing parsed definition in applicative Kore syntax "
121111
++ "[default disabled]"
122112
)
123-
124-
-- TODO (MirceaS): Refactor the code that uses the
125-
-- command line parser so that it uses the new
126-
-- KoreParserOptions options type so that we may
127-
-- remove the terms below
128-
129-
morph :: KoreParserOptions' -> KoreParserOptions
130-
morph kpo
131-
| Nothing <- patternOpt = KoreParserOptions
132-
{ fileName
133-
, patternFileName = ""
134-
, mainModuleName = ""
135-
, willPrintDefinition
136-
, willPrintPattern
137-
, willVerify
138-
, appKore
139-
}
140-
| Just PatternOptions
141-
{ patternFileName
142-
, mainModuleName
143-
} <- patternOpt = KoreParserOptions
144-
{ fileName
145-
, patternFileName
146-
, mainModuleName
147-
, willPrintDefinition
148-
, willPrintPattern
149-
, willVerify
150-
, appKore
151-
}
152-
where
153-
KoreParserOptions'
154-
{ fileName
155-
, patternOpt
156-
, willPrintDefinition
157-
, willPrintPattern
158-
, willVerify
159-
, appKore
160-
} = kpo
161-
162-
commandLineParser :: Parser KoreParserOptions
163-
commandLineParser = morph <$> commandLineParser'

0 commit comments

Comments
 (0)