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/printer_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 |
|
template <> options::flattenHOChains__option_t::type& Options::ref( |
29 |
|
options::flattenHOChains__option_t) |
30 |
|
{ |
31 |
|
return printer().flattenHOChains; |
32 |
|
} |
33 |
|
template <> const options::flattenHOChains__option_t::type& Options::operator[]( |
34 |
|
options::flattenHOChains__option_t) const |
35 |
|
{ |
36 |
|
return printer().flattenHOChains; |
37 |
|
} |
38 |
|
template <> bool Options::wasSetByUser(options::flattenHOChains__option_t) const |
39 |
|
{ |
40 |
|
return printer().flattenHOChains__setByUser__; |
41 |
|
} |
42 |
|
template <> options::instFormatMode__option_t::type& Options::ref( |
43 |
|
options::instFormatMode__option_t) |
44 |
|
{ |
45 |
|
return printer().instFormatMode; |
46 |
|
} |
47 |
183 |
template <> const options::instFormatMode__option_t::type& Options::operator[]( |
48 |
|
options::instFormatMode__option_t) const |
49 |
|
{ |
50 |
183 |
return printer().instFormatMode; |
51 |
|
} |
52 |
|
template <> bool Options::wasSetByUser(options::instFormatMode__option_t) const |
53 |
|
{ |
54 |
|
return printer().instFormatMode__setByUser__; |
55 |
|
} |
56 |
|
template <> options::modelFormatMode__option_t::type& Options::ref( |
57 |
|
options::modelFormatMode__option_t) |
58 |
|
{ |
59 |
|
return printer().modelFormatMode; |
60 |
|
} |
61 |
|
template <> const options::modelFormatMode__option_t::type& Options::operator[]( |
62 |
|
options::modelFormatMode__option_t) const |
63 |
|
{ |
64 |
|
return printer().modelFormatMode; |
65 |
|
} |
66 |
|
template <> bool Options::wasSetByUser(options::modelFormatMode__option_t) const |
67 |
|
{ |
68 |
|
return printer().modelFormatMode__setByUser__; |
69 |
|
} |
70 |
|
template <> options::printInstFull__option_t::type& Options::ref( |
71 |
|
options::printInstFull__option_t) |
72 |
|
{ |
73 |
|
return printer().printInstFull; |
74 |
|
} |
75 |
17 |
template <> const options::printInstFull__option_t::type& Options::operator[]( |
76 |
|
options::printInstFull__option_t) const |
77 |
|
{ |
78 |
17 |
return printer().printInstFull; |
79 |
|
} |
80 |
|
template <> bool Options::wasSetByUser(options::printInstFull__option_t) const |
81 |
|
{ |
82 |
|
return printer().printInstFull__setByUser__; |
83 |
|
} |
84 |
|
template <> options::printInstMode__option_t::type& Options::ref( |
85 |
|
options::printInstMode__option_t) |
86 |
|
{ |
87 |
|
return printer().printInstMode; |
88 |
|
} |
89 |
51 |
template <> const options::printInstMode__option_t::type& Options::operator[]( |
90 |
|
options::printInstMode__option_t) const |
91 |
|
{ |
92 |
51 |
return printer().printInstMode; |
93 |
|
} |
94 |
|
template <> bool Options::wasSetByUser(options::printInstMode__option_t) const |
95 |
|
{ |
96 |
|
return printer().printInstMode__setByUser__; |
97 |
|
} |
98 |
|
|
99 |
|
namespace options { |
100 |
|
|
101 |
|
thread_local struct flattenHOChains__option_t flattenHOChains; |
102 |
|
thread_local struct instFormatMode__option_t instFormatMode; |
103 |
|
thread_local struct modelFormatMode__option_t modelFormatMode; |
104 |
|
thread_local struct printInstFull__option_t printInstFull; |
105 |
|
thread_local struct printInstMode__option_t printInstMode; |
106 |
|
|
107 |
|
|
108 |
|
std::ostream& operator<<(std::ostream& os, ModelFormatMode mode) |
109 |
|
{ |
110 |
|
switch(mode) { |
111 |
|
case ModelFormatMode::TABLE: |
112 |
|
return os << "ModelFormatMode::TABLE"; |
113 |
|
case ModelFormatMode::DEFAULT: |
114 |
|
return os << "ModelFormatMode::DEFAULT"; |
115 |
|
default: |
116 |
|
Unreachable(); |
117 |
|
} |
118 |
|
return os; |
119 |
|
} |
120 |
|
|
121 |
|
ModelFormatMode stringToModelFormatMode(const std::string& optarg) |
122 |
|
{ |
123 |
|
if (optarg == "table") |
124 |
|
{ |
125 |
|
return ModelFormatMode::TABLE; |
126 |
|
} |
127 |
|
else if (optarg == "default") |
128 |
|
{ |
129 |
|
return ModelFormatMode::DEFAULT; |
130 |
|
} |
131 |
|
else if (optarg == "help") |
132 |
|
{ |
133 |
|
std::cerr << "Model format modes.\n" |
134 |
|
"Available modes for --model-format are:\n" |
135 |
|
"+ table\n" |
136 |
|
" Print functional expressions over finite domains in a table format.\n" |
137 |
|
"+ default\n" |
138 |
|
" Print model as expressions in the output language format.\n"; |
139 |
|
std::exit(1); |
140 |
|
} |
141 |
|
throw OptionException(std::string("unknown option for --model-format: `") + |
142 |
|
optarg + "'. Try --model-format=help."); |
143 |
|
} |
144 |
|
|
145 |
|
std::ostream& operator<<(std::ostream& os, PrintInstMode mode) |
146 |
|
{ |
147 |
|
switch(mode) { |
148 |
|
case PrintInstMode::NUM: |
149 |
|
return os << "PrintInstMode::NUM"; |
150 |
|
case PrintInstMode::LIST: |
151 |
|
return os << "PrintInstMode::LIST"; |
152 |
|
default: |
153 |
|
Unreachable(); |
154 |
|
} |
155 |
|
return os; |
156 |
|
} |
157 |
|
|
158 |
3 |
PrintInstMode stringToPrintInstMode(const std::string& optarg) |
159 |
|
{ |
160 |
3 |
if (optarg == "num") |
161 |
|
{ |
162 |
3 |
return PrintInstMode::NUM; |
163 |
|
} |
164 |
|
else if (optarg == "list") |
165 |
|
{ |
166 |
|
return PrintInstMode::LIST; |
167 |
|
} |
168 |
|
else if (optarg == "help") |
169 |
|
{ |
170 |
|
std::cerr << "Print format for printing instantiations.\n" |
171 |
|
"Available modes for --print-inst are:\n" |
172 |
|
"+ num\n" |
173 |
|
" Print the total number of instantiations per quantified formula, when\n" |
174 |
|
" non-zero.\n" |
175 |
|
"+ list (default)\n" |
176 |
|
" Print the list of instantiations per quantified formula, when non-empty.\n"; |
177 |
|
std::exit(1); |
178 |
|
} |
179 |
|
throw OptionException(std::string("unknown option for --print-inst: `") + |
180 |
|
optarg + "'. Try --print-inst=help."); |
181 |
|
} |
182 |
|
|
183 |
|
|
184 |
|
} // namespace options |
185 |
28191 |
} // namespace cvc5 |
186 |
|
// clang-format on |