1 |
|
/****************************************************************************** |
2 |
|
* Top contributors (to current version): |
3 |
|
* Mathias Preiner, Aina Niemetz |
4 |
|
* |
5 |
|
* This file is part of the cvc5 project. |
6 |
|
* |
7 |
|
* Copyright (c) 2009-2021 by the authors listed in the file AUTHORS |
8 |
|
* in the top-level source directory and their institutional affiliations. |
9 |
|
* All rights reserved. See the file COPYING in the top-level source |
10 |
|
* directory for licensing information. |
11 |
|
* **************************************************************************** |
12 |
|
* |
13 |
|
* Option template for option modules. |
14 |
|
* |
15 |
|
* For each <module>_options.toml configuration file, mkoptions.py |
16 |
|
* expands this template and generates a <module>_options.cpp file. |
17 |
|
*/ |
18 |
|
#include "options/strings_options.h" |
19 |
|
|
20 |
|
#include <iostream> |
21 |
|
|
22 |
|
#include "base/check.h" |
23 |
|
#include "options/option_exception.h" |
24 |
|
|
25 |
|
// clang-format off |
26 |
|
namespace cvc5 { |
27 |
|
|
28 |
|
|
29 |
|
|
30 |
|
namespace options { |
31 |
|
|
32 |
|
thread_local struct regExpElim__option_t regExpElim; |
33 |
|
thread_local struct regExpElimAgg__option_t regExpElimAgg; |
34 |
|
thread_local struct stringRegExpInterMode__option_t stringRegExpInterMode; |
35 |
|
thread_local struct stringCheckEntailLen__option_t stringCheckEntailLen; |
36 |
|
thread_local struct stringEager__option_t stringEager; |
37 |
|
thread_local struct stringEagerEval__option_t stringEagerEval; |
38 |
|
thread_local struct stringEagerLen__option_t stringEagerLen; |
39 |
|
thread_local struct stringExp__option_t stringExp; |
40 |
|
thread_local struct stringFlatForms__option_t stringFlatForms; |
41 |
|
thread_local struct stringFMF__option_t stringFMF; |
42 |
|
thread_local struct stringGuessModel__option_t stringGuessModel; |
43 |
|
thread_local struct stringInferAsLemmas__option_t stringInferAsLemmas; |
44 |
|
thread_local struct stringInferSym__option_t stringInferSym; |
45 |
|
thread_local struct stringLazyPreproc__option_t stringLazyPreproc; |
46 |
|
thread_local struct stringLenNorm__option_t stringLenNorm; |
47 |
|
thread_local struct stringLenPropCsp__option_t stringLenPropCsp; |
48 |
|
thread_local struct stringMinPrefixExplain__option_t stringMinPrefixExplain; |
49 |
|
thread_local struct stringProcessLoopMode__option_t stringProcessLoopMode; |
50 |
|
thread_local struct stringRExplainLemmas__option_t stringRExplainLemmas; |
51 |
|
thread_local struct stringUnifiedVSpt__option_t stringUnifiedVSpt; |
52 |
|
|
53 |
|
|
54 |
|
std::ostream& operator<<(std::ostream& os, RegExpInterMode mode) |
55 |
|
{ |
56 |
|
switch(mode) { |
57 |
|
case RegExpInterMode::NONE: |
58 |
|
return os << "RegExpInterMode::NONE"; |
59 |
|
case RegExpInterMode::CONSTANT: |
60 |
|
return os << "RegExpInterMode::CONSTANT"; |
61 |
|
case RegExpInterMode::ALL: |
62 |
|
return os << "RegExpInterMode::ALL"; |
63 |
|
case RegExpInterMode::ONE_CONSTANT: |
64 |
|
return os << "RegExpInterMode::ONE_CONSTANT"; |
65 |
|
default: |
66 |
|
Unreachable(); |
67 |
|
} |
68 |
|
return os; |
69 |
|
} |
70 |
|
|
71 |
|
RegExpInterMode stringToRegExpInterMode(const std::string& optarg) |
72 |
|
{ |
73 |
|
if (optarg == "none") |
74 |
|
{ |
75 |
|
return RegExpInterMode::NONE; |
76 |
|
} |
77 |
|
else if (optarg == "constant") |
78 |
|
{ |
79 |
|
return RegExpInterMode::CONSTANT; |
80 |
|
} |
81 |
|
else if (optarg == "all") |
82 |
|
{ |
83 |
|
return RegExpInterMode::ALL; |
84 |
|
} |
85 |
|
else if (optarg == "one-constant") |
86 |
|
{ |
87 |
|
return RegExpInterMode::ONE_CONSTANT; |
88 |
|
} |
89 |
|
else if (optarg == "help") |
90 |
|
{ |
91 |
|
std::cerr << "Regular expression intersection modes.\n" |
92 |
|
"Available modes for --re-inter-mode are:\n" |
93 |
|
"+ none\n" |
94 |
|
" Do not compute intersections for regular expressions.\n" |
95 |
|
"+ constant (default)\n" |
96 |
|
" Compute intersections only between regular expressions that do not contain\n" |
97 |
|
" re.allchar or re.range.\n" |
98 |
|
"+ all\n" |
99 |
|
" Compute intersections for all regular expressions.\n" |
100 |
|
"+ one-constant\n" |
101 |
|
" Compute intersections only between regular expressions such that at least one\n" |
102 |
|
" side does not contain re.allchar or re.range.\n"; |
103 |
|
std::exit(1); |
104 |
|
} |
105 |
|
throw OptionException(std::string("unknown option for --re-inter-mode: `") + |
106 |
|
optarg + "'. Try --re-inter-mode=help."); |
107 |
|
} |
108 |
|
|
109 |
|
std::ostream& operator<<(std::ostream& os, ProcessLoopMode mode) |
110 |
|
{ |
111 |
|
switch(mode) { |
112 |
|
case ProcessLoopMode::NONE: |
113 |
|
return os << "ProcessLoopMode::NONE"; |
114 |
|
case ProcessLoopMode::ABORT: |
115 |
|
return os << "ProcessLoopMode::ABORT"; |
116 |
|
case ProcessLoopMode::SIMPLE_ABORT: |
117 |
|
return os << "ProcessLoopMode::SIMPLE_ABORT"; |
118 |
|
case ProcessLoopMode::SIMPLE: |
119 |
|
return os << "ProcessLoopMode::SIMPLE"; |
120 |
|
case ProcessLoopMode::FULL: |
121 |
|
return os << "ProcessLoopMode::FULL"; |
122 |
|
default: |
123 |
|
Unreachable(); |
124 |
|
} |
125 |
|
return os; |
126 |
|
} |
127 |
|
|
128 |
|
ProcessLoopMode stringToProcessLoopMode(const std::string& optarg) |
129 |
|
{ |
130 |
|
if (optarg == "none") |
131 |
|
{ |
132 |
|
return ProcessLoopMode::NONE; |
133 |
|
} |
134 |
|
else if (optarg == "abort") |
135 |
|
{ |
136 |
|
return ProcessLoopMode::ABORT; |
137 |
|
} |
138 |
|
else if (optarg == "simple-abort") |
139 |
|
{ |
140 |
|
return ProcessLoopMode::SIMPLE_ABORT; |
141 |
|
} |
142 |
|
else if (optarg == "simple") |
143 |
|
{ |
144 |
|
return ProcessLoopMode::SIMPLE; |
145 |
|
} |
146 |
|
else if (optarg == "full") |
147 |
|
{ |
148 |
|
return ProcessLoopMode::FULL; |
149 |
|
} |
150 |
|
else if (optarg == "help") |
151 |
|
{ |
152 |
|
std::cerr << "Loop processing modes.\n" |
153 |
|
"Available modes for --strings-process-loop-mode are:\n" |
154 |
|
"+ none\n" |
155 |
|
" Omit loop processing.\n" |
156 |
|
"+ abort\n" |
157 |
|
" Abort if looping word equations are encountered.\n" |
158 |
|
"+ simple-abort\n" |
159 |
|
" Abort when normal loop breaking is required.\n" |
160 |
|
"+ simple\n" |
161 |
|
" Omit normal loop breaking (default with --strings-fmf).\n" |
162 |
|
"+ full (default)\n" |
163 |
|
" Perform full processing of looping word equations.\n"; |
164 |
|
std::exit(1); |
165 |
|
} |
166 |
|
throw OptionException(std::string("unknown option for --strings-process-loop-mode: `") + |
167 |
|
optarg + "'. Try --strings-process-loop-mode=help."); |
168 |
|
} |
169 |
|
|
170 |
|
|
171 |
|
|
172 |
|
namespace strings |
173 |
|
{ |
174 |
|
// clang-format off |
175 |
|
void setDefaultRegExpElim(Options& opts, bool value) |
176 |
|
{ |
177 |
|
if (!opts.strings.regExpElimWasSetByUser) { |
178 |
|
opts.strings.regExpElim = value; |
179 |
|
} |
180 |
|
} |
181 |
|
void setDefaultRegExpElimAgg(Options& opts, bool value) |
182 |
|
{ |
183 |
|
if (!opts.strings.regExpElimAggWasSetByUser) { |
184 |
|
opts.strings.regExpElimAgg = value; |
185 |
|
} |
186 |
|
} |
187 |
|
void setDefaultStringRegExpInterMode(Options& opts, RegExpInterMode value) |
188 |
|
{ |
189 |
|
if (!opts.strings.stringRegExpInterModeWasSetByUser) { |
190 |
|
opts.strings.stringRegExpInterMode = value; |
191 |
|
} |
192 |
|
} |
193 |
|
void setDefaultStringCheckEntailLen(Options& opts, bool value) |
194 |
|
{ |
195 |
|
if (!opts.strings.stringCheckEntailLenWasSetByUser) { |
196 |
|
opts.strings.stringCheckEntailLen = value; |
197 |
|
} |
198 |
|
} |
199 |
|
void setDefaultStringEager(Options& opts, bool value) |
200 |
|
{ |
201 |
|
if (!opts.strings.stringEagerWasSetByUser) { |
202 |
|
opts.strings.stringEager = value; |
203 |
|
} |
204 |
|
} |
205 |
|
void setDefaultStringEagerEval(Options& opts, bool value) |
206 |
|
{ |
207 |
|
if (!opts.strings.stringEagerEvalWasSetByUser) { |
208 |
|
opts.strings.stringEagerEval = value; |
209 |
|
} |
210 |
|
} |
211 |
|
void setDefaultStringEagerLen(Options& opts, bool value) |
212 |
|
{ |
213 |
|
if (!opts.strings.stringEagerLenWasSetByUser) { |
214 |
|
opts.strings.stringEagerLen = value; |
215 |
|
} |
216 |
|
} |
217 |
|
void setDefaultStringExp(Options& opts, bool value) |
218 |
|
{ |
219 |
|
if (!opts.strings.stringExpWasSetByUser) { |
220 |
|
opts.strings.stringExp = value; |
221 |
|
} |
222 |
|
} |
223 |
|
void setDefaultStringFlatForms(Options& opts, bool value) |
224 |
|
{ |
225 |
|
if (!opts.strings.stringFlatFormsWasSetByUser) { |
226 |
|
opts.strings.stringFlatForms = value; |
227 |
|
} |
228 |
|
} |
229 |
|
void setDefaultStringFMF(Options& opts, bool value) |
230 |
|
{ |
231 |
|
if (!opts.strings.stringFMFWasSetByUser) { |
232 |
|
opts.strings.stringFMF = value; |
233 |
|
} |
234 |
|
} |
235 |
|
void setDefaultStringGuessModel(Options& opts, bool value) |
236 |
|
{ |
237 |
|
if (!opts.strings.stringGuessModelWasSetByUser) { |
238 |
|
opts.strings.stringGuessModel = value; |
239 |
|
} |
240 |
|
} |
241 |
|
void setDefaultStringInferAsLemmas(Options& opts, bool value) |
242 |
|
{ |
243 |
|
if (!opts.strings.stringInferAsLemmasWasSetByUser) { |
244 |
|
opts.strings.stringInferAsLemmas = value; |
245 |
|
} |
246 |
|
} |
247 |
|
void setDefaultStringInferSym(Options& opts, bool value) |
248 |
|
{ |
249 |
|
if (!opts.strings.stringInferSymWasSetByUser) { |
250 |
|
opts.strings.stringInferSym = value; |
251 |
|
} |
252 |
|
} |
253 |
|
void setDefaultStringLazyPreproc(Options& opts, bool value) |
254 |
|
{ |
255 |
|
if (!opts.strings.stringLazyPreprocWasSetByUser) { |
256 |
|
opts.strings.stringLazyPreproc = value; |
257 |
|
} |
258 |
|
} |
259 |
|
void setDefaultStringLenNorm(Options& opts, bool value) |
260 |
|
{ |
261 |
|
if (!opts.strings.stringLenNormWasSetByUser) { |
262 |
|
opts.strings.stringLenNorm = value; |
263 |
|
} |
264 |
|
} |
265 |
|
void setDefaultStringLenPropCsp(Options& opts, bool value) |
266 |
|
{ |
267 |
|
if (!opts.strings.stringLenPropCspWasSetByUser) { |
268 |
|
opts.strings.stringLenPropCsp = value; |
269 |
|
} |
270 |
|
} |
271 |
|
void setDefaultStringMinPrefixExplain(Options& opts, bool value) |
272 |
|
{ |
273 |
|
if (!opts.strings.stringMinPrefixExplainWasSetByUser) { |
274 |
|
opts.strings.stringMinPrefixExplain = value; |
275 |
|
} |
276 |
|
} |
277 |
|
void setDefaultStringProcessLoopMode(Options& opts, ProcessLoopMode value) |
278 |
|
{ |
279 |
|
if (!opts.strings.stringProcessLoopModeWasSetByUser) { |
280 |
|
opts.strings.stringProcessLoopMode = value; |
281 |
|
} |
282 |
|
} |
283 |
|
void setDefaultStringRExplainLemmas(Options& opts, bool value) |
284 |
|
{ |
285 |
|
if (!opts.strings.stringRExplainLemmasWasSetByUser) { |
286 |
|
opts.strings.stringRExplainLemmas = value; |
287 |
|
} |
288 |
|
} |
289 |
|
void setDefaultStringUnifiedVSpt(Options& opts, bool value) |
290 |
|
{ |
291 |
|
if (!opts.strings.stringUnifiedVSptWasSetByUser) { |
292 |
|
opts.strings.stringUnifiedVSpt = value; |
293 |
|
} |
294 |
|
} |
295 |
|
// clang-format on |
296 |
|
} |
297 |
|
|
298 |
|
} // namespace options |
299 |
29286 |
} // namespace cvc5 |
300 |
|
// clang-format on |