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::options { |
27 |
|
|
28 |
|
std::ostream& operator<<(std::ostream& os, RegExpInterMode mode) |
29 |
|
{ |
30 |
|
switch(mode) { |
31 |
|
case RegExpInterMode::NONE: |
32 |
|
return os << "RegExpInterMode::NONE"; |
33 |
|
case RegExpInterMode::CONSTANT: |
34 |
|
return os << "RegExpInterMode::CONSTANT"; |
35 |
|
case RegExpInterMode::ONE_CONSTANT: |
36 |
|
return os << "RegExpInterMode::ONE_CONSTANT"; |
37 |
|
case RegExpInterMode::ALL: |
38 |
|
return os << "RegExpInterMode::ALL"; |
39 |
|
default: |
40 |
|
Unreachable(); |
41 |
|
} |
42 |
|
return os; |
43 |
|
} |
44 |
|
RegExpInterMode stringToRegExpInterMode(const std::string& optarg) |
45 |
|
{ |
46 |
|
if (optarg == "none") |
47 |
|
{ |
48 |
|
return RegExpInterMode::NONE; |
49 |
|
} |
50 |
|
else if (optarg == "constant") |
51 |
|
{ |
52 |
|
return RegExpInterMode::CONSTANT; |
53 |
|
} |
54 |
|
else if (optarg == "one-constant") |
55 |
|
{ |
56 |
|
return RegExpInterMode::ONE_CONSTANT; |
57 |
|
} |
58 |
|
else if (optarg == "all") |
59 |
|
{ |
60 |
|
return RegExpInterMode::ALL; |
61 |
|
} |
62 |
|
else if (optarg == "help") |
63 |
|
{ |
64 |
|
std::cerr << "Regular expression intersection modes.\n" |
65 |
|
"Available modes for --re-inter-mode are:\n" |
66 |
|
"+ none\n" |
67 |
|
" Do not compute intersections for regular expressions.\n" |
68 |
|
"+ constant (default)\n" |
69 |
|
" Compute intersections only between regular expressions that do not contain\n" |
70 |
|
" re.allchar or re.range.\n" |
71 |
|
"+ one-constant\n" |
72 |
|
" Compute intersections only between regular expressions such that at least one\n" |
73 |
|
" side does not contain re.allchar or re.range.\n" |
74 |
|
"+ all\n" |
75 |
|
" Compute intersections for all regular expressions.\n"; |
76 |
|
std::exit(1); |
77 |
|
} |
78 |
|
throw OptionException(std::string("unknown option for --re-inter-mode: `") + |
79 |
|
optarg + "'. Try --re-inter-mode=help."); |
80 |
|
} |
81 |
|
std::ostream& operator<<(std::ostream& os, ProcessLoopMode mode) |
82 |
|
{ |
83 |
|
switch(mode) { |
84 |
|
case ProcessLoopMode::NONE: |
85 |
|
return os << "ProcessLoopMode::NONE"; |
86 |
|
case ProcessLoopMode::SIMPLE: |
87 |
|
return os << "ProcessLoopMode::SIMPLE"; |
88 |
|
case ProcessLoopMode::ABORT: |
89 |
|
return os << "ProcessLoopMode::ABORT"; |
90 |
|
case ProcessLoopMode::SIMPLE_ABORT: |
91 |
|
return os << "ProcessLoopMode::SIMPLE_ABORT"; |
92 |
|
case ProcessLoopMode::FULL: |
93 |
|
return os << "ProcessLoopMode::FULL"; |
94 |
|
default: |
95 |
|
Unreachable(); |
96 |
|
} |
97 |
|
return os; |
98 |
|
} |
99 |
|
ProcessLoopMode stringToProcessLoopMode(const std::string& optarg) |
100 |
|
{ |
101 |
|
if (optarg == "none") |
102 |
|
{ |
103 |
|
return ProcessLoopMode::NONE; |
104 |
|
} |
105 |
|
else if (optarg == "simple") |
106 |
|
{ |
107 |
|
return ProcessLoopMode::SIMPLE; |
108 |
|
} |
109 |
|
else if (optarg == "abort") |
110 |
|
{ |
111 |
|
return ProcessLoopMode::ABORT; |
112 |
|
} |
113 |
|
else if (optarg == "simple-abort") |
114 |
|
{ |
115 |
|
return ProcessLoopMode::SIMPLE_ABORT; |
116 |
|
} |
117 |
|
else if (optarg == "full") |
118 |
|
{ |
119 |
|
return ProcessLoopMode::FULL; |
120 |
|
} |
121 |
|
else if (optarg == "help") |
122 |
|
{ |
123 |
|
std::cerr << "Loop processing modes.\n" |
124 |
|
"Available modes for --strings-process-loop-mode are:\n" |
125 |
|
"+ none\n" |
126 |
|
" Omit loop processing.\n" |
127 |
|
"+ simple\n" |
128 |
|
" Omit normal loop breaking (default with --strings-fmf).\n" |
129 |
|
"+ abort\n" |
130 |
|
" Abort if looping word equations are encountered.\n" |
131 |
|
"+ simple-abort\n" |
132 |
|
" Abort when normal loop breaking is required.\n" |
133 |
|
"+ full (default)\n" |
134 |
|
" Perform full processing of looping word equations.\n"; |
135 |
|
std::exit(1); |
136 |
|
} |
137 |
|
throw OptionException(std::string("unknown option for --strings-process-loop-mode: `") + |
138 |
|
optarg + "'. Try --strings-process-loop-mode=help."); |
139 |
|
} |
140 |
|
|
141 |
|
namespace strings |
142 |
|
{ |
143 |
|
// clang-format off |
144 |
|
void setDefaultRegExpElim(Options& opts, bool value) |
145 |
|
{ |
146 |
|
if (!opts.strings.regExpElimWasSetByUser) { |
147 |
|
opts.strings.regExpElim = value; |
148 |
|
} |
149 |
|
} |
150 |
|
void setDefaultRegExpElimAgg(Options& opts, bool value) |
151 |
|
{ |
152 |
|
if (!opts.strings.regExpElimAggWasSetByUser) { |
153 |
|
opts.strings.regExpElimAgg = value; |
154 |
|
} |
155 |
|
} |
156 |
|
void setDefaultStringRegExpInterMode(Options& opts, RegExpInterMode value) |
157 |
|
{ |
158 |
|
if (!opts.strings.stringRegExpInterModeWasSetByUser) { |
159 |
|
opts.strings.stringRegExpInterMode = value; |
160 |
|
} |
161 |
|
} |
162 |
|
void setDefaultStringCheckEntailLen(Options& opts, bool value) |
163 |
|
{ |
164 |
|
if (!opts.strings.stringCheckEntailLenWasSetByUser) { |
165 |
|
opts.strings.stringCheckEntailLen = value; |
166 |
|
} |
167 |
|
} |
168 |
|
void setDefaultStringEager(Options& opts, bool value) |
169 |
|
{ |
170 |
|
if (!opts.strings.stringEagerWasSetByUser) { |
171 |
|
opts.strings.stringEager = value; |
172 |
|
} |
173 |
|
} |
174 |
|
void setDefaultStringEagerEval(Options& opts, bool value) |
175 |
|
{ |
176 |
|
if (!opts.strings.stringEagerEvalWasSetByUser) { |
177 |
|
opts.strings.stringEagerEval = value; |
178 |
|
} |
179 |
|
} |
180 |
|
void setDefaultStringEagerLen(Options& opts, bool value) |
181 |
|
{ |
182 |
|
if (!opts.strings.stringEagerLenWasSetByUser) { |
183 |
|
opts.strings.stringEagerLen = value; |
184 |
|
} |
185 |
|
} |
186 |
|
void setDefaultStringExp(Options& opts, bool value) |
187 |
|
{ |
188 |
|
if (!opts.strings.stringExpWasSetByUser) { |
189 |
|
opts.strings.stringExp = value; |
190 |
|
} |
191 |
|
} |
192 |
|
void setDefaultStringFlatForms(Options& opts, bool value) |
193 |
|
{ |
194 |
|
if (!opts.strings.stringFlatFormsWasSetByUser) { |
195 |
|
opts.strings.stringFlatForms = value; |
196 |
|
} |
197 |
|
} |
198 |
|
void setDefaultStringFMF(Options& opts, bool value) |
199 |
|
{ |
200 |
|
if (!opts.strings.stringFMFWasSetByUser) { |
201 |
|
opts.strings.stringFMF = value; |
202 |
|
} |
203 |
|
} |
204 |
|
void setDefaultStringGuessModel(Options& opts, bool value) |
205 |
|
{ |
206 |
|
if (!opts.strings.stringGuessModelWasSetByUser) { |
207 |
|
opts.strings.stringGuessModel = value; |
208 |
|
} |
209 |
|
} |
210 |
|
void setDefaultStringInferAsLemmas(Options& opts, bool value) |
211 |
|
{ |
212 |
|
if (!opts.strings.stringInferAsLemmasWasSetByUser) { |
213 |
|
opts.strings.stringInferAsLemmas = value; |
214 |
|
} |
215 |
|
} |
216 |
|
void setDefaultStringInferSym(Options& opts, bool value) |
217 |
|
{ |
218 |
|
if (!opts.strings.stringInferSymWasSetByUser) { |
219 |
|
opts.strings.stringInferSym = value; |
220 |
|
} |
221 |
|
} |
222 |
|
void setDefaultStringLazyPreproc(Options& opts, bool value) |
223 |
|
{ |
224 |
|
if (!opts.strings.stringLazyPreprocWasSetByUser) { |
225 |
|
opts.strings.stringLazyPreproc = value; |
226 |
|
} |
227 |
|
} |
228 |
|
void setDefaultStringLenNorm(Options& opts, bool value) |
229 |
|
{ |
230 |
|
if (!opts.strings.stringLenNormWasSetByUser) { |
231 |
|
opts.strings.stringLenNorm = value; |
232 |
|
} |
233 |
|
} |
234 |
|
void setDefaultStringLenPropCsp(Options& opts, bool value) |
235 |
|
{ |
236 |
|
if (!opts.strings.stringLenPropCspWasSetByUser) { |
237 |
|
opts.strings.stringLenPropCsp = value; |
238 |
|
} |
239 |
|
} |
240 |
|
void setDefaultStringMinPrefixExplain(Options& opts, bool value) |
241 |
|
{ |
242 |
|
if (!opts.strings.stringMinPrefixExplainWasSetByUser) { |
243 |
|
opts.strings.stringMinPrefixExplain = value; |
244 |
|
} |
245 |
|
} |
246 |
|
void setDefaultStringProcessLoopMode(Options& opts, ProcessLoopMode value) |
247 |
|
{ |
248 |
|
if (!opts.strings.stringProcessLoopModeWasSetByUser) { |
249 |
|
opts.strings.stringProcessLoopMode = value; |
250 |
|
} |
251 |
|
} |
252 |
|
void setDefaultStringRExplainLemmas(Options& opts, bool value) |
253 |
|
{ |
254 |
|
if (!opts.strings.stringRExplainLemmasWasSetByUser) { |
255 |
|
opts.strings.stringRExplainLemmas = value; |
256 |
|
} |
257 |
|
} |
258 |
|
void setDefaultStringUnifiedVSpt(Options& opts, bool value) |
259 |
|
{ |
260 |
|
if (!opts.strings.stringUnifiedVSptWasSetByUser) { |
261 |
|
opts.strings.stringUnifiedVSpt = value; |
262 |
|
} |
263 |
|
} |
264 |
|
// clang-format on |
265 |
|
} |
266 |
|
|
267 |
29499 |
} // namespace cvc5::options |
268 |
|
// clang-format on |