@@ -48,14 +48,20 @@ enableDisableFlag name enabledVal disabledVal defaultVal helpSuffix =
48
48
<> help ( " Enable/disable " ++ helpSuffix ) )
49
49
<|> pure defaultVal
50
50
51
- -- | Main options record
52
- data KoreParserOptions = KoreParserOptions
53
- { fileName :: ! FilePath
54
- -- ^ Name for a file containing a definition to parse and verify
55
- , patternFileName :: ! FilePath
51
+
52
+ data PatternOptions = PatternOptions
53
+ { patternFileName :: ! FilePath
56
54
-- ^ Name for file containing a pattern to parse and verify
57
55
, mainModuleName :: ! Text
58
56
-- ^ the name of the main module in the definition
57
+ }
58
+
59
+ -- | Main options record
60
+ data KoreParserOptions' = KoreParserOptions'
61
+ { fileName :: ! FilePath
62
+ -- ^ Name for a file containing a definition to parse and verify
63
+ , patternOpt :: ! (Maybe PatternOptions )
64
+ -- ^ Optional options for parsing a pattern
59
65
, willPrintDefinition :: ! Bool
60
66
-- ^ Option to print definition
61
67
, willPrintPattern :: ! Bool
@@ -66,24 +72,40 @@ data KoreParserOptions = KoreParserOptions
66
72
-- ^ Option to print in applicative Kore syntax
67
73
}
68
74
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
+
69
86
-- | Command Line Argument Parser
70
- commandLineParser :: Parser KoreParserOptions
71
- commandLineParser =
72
- KoreParserOptions
87
+ commandLineParser' :: Parser KoreParserOptions'
88
+ commandLineParser' =
89
+ KoreParserOptions'
73
90
<$> argument str
74
91
( metavar " FILE"
75
92
<> help " Kore source file to parse [and verify]" )
76
- <*> strOption
77
- ( metavar " PATTERN_FILE"
78
- <> long " pattern"
79
- <> help
80
- " Kore pattern source file to parse [and verify]. Needs --module."
81
- <> value " " )
82
- <*> strOption
83
- ( metavar " MODULE"
84
- <> long " module"
85
- <> help " The name of the main module in the Kore definition"
86
- <> value " " )
93
+ <*> ( (Just <$>
94
+ (PatternOptions
95
+ <$> strOption
96
+ ( metavar " PATTERN_FILE"
97
+ <> long " pattern"
98
+ <> help " Kore pattern source file to parse [and verify]. Needs --module." )
99
+ <*> strOption
100
+ ( metavar " MODULE"
101
+ <> long " module"
102
+ <> help " The name of the main module in the Kore definition" )
103
+ )
104
+ )
105
+ <|> flag Nothing Nothing
106
+ ( long " definition-only"
107
+ <> help " No Kore pattern may be checked against the definition" )
108
+ )
87
109
<*> enableDisableFlag " print-definition"
88
110
True False False
89
111
" printing parsed definition to stdout [default disabled]"
@@ -98,3 +120,44 @@ commandLineParser =
98
120
( " printing parsed definition in applicative Kore syntax "
99
121
++ " [default disabled]"
100
122
)
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