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 |
|
|
29 |
|
|
30 |
|
namespace options { |
31 |
|
|
32 |
|
thread_local struct flattenHOChains__option_t flattenHOChains; |
33 |
|
thread_local struct instFormatMode__option_t instFormatMode; |
34 |
|
thread_local struct modelFormatMode__option_t modelFormatMode; |
35 |
|
thread_local struct printInstFull__option_t printInstFull; |
36 |
|
thread_local struct printInstMode__option_t printInstMode; |
37 |
|
|
38 |
|
|
39 |
|
std::ostream& operator<<(std::ostream& os, ModelFormatMode mode) |
40 |
|
{ |
41 |
|
switch(mode) { |
42 |
|
case ModelFormatMode::TABLE: |
43 |
|
return os << "ModelFormatMode::TABLE"; |
44 |
|
case ModelFormatMode::DEFAULT: |
45 |
|
return os << "ModelFormatMode::DEFAULT"; |
46 |
|
default: |
47 |
|
Unreachable(); |
48 |
|
} |
49 |
|
return os; |
50 |
|
} |
51 |
|
|
52 |
|
ModelFormatMode stringToModelFormatMode(const std::string& optarg) |
53 |
|
{ |
54 |
|
if (optarg == "table") |
55 |
|
{ |
56 |
|
return ModelFormatMode::TABLE; |
57 |
|
} |
58 |
|
else if (optarg == "default") |
59 |
|
{ |
60 |
|
return ModelFormatMode::DEFAULT; |
61 |
|
} |
62 |
|
else if (optarg == "help") |
63 |
|
{ |
64 |
|
std::cerr << "Model format modes.\n" |
65 |
|
"Available modes for --model-format are:\n" |
66 |
|
"+ table\n" |
67 |
|
" Print functional expressions over finite domains in a table format.\n" |
68 |
|
"+ default\n" |
69 |
|
" Print model as expressions in the output language format.\n"; |
70 |
|
std::exit(1); |
71 |
|
} |
72 |
|
throw OptionException(std::string("unknown option for --model-format: `") + |
73 |
|
optarg + "'. Try --model-format=help."); |
74 |
|
} |
75 |
|
|
76 |
|
std::ostream& operator<<(std::ostream& os, PrintInstMode mode) |
77 |
|
{ |
78 |
|
switch(mode) { |
79 |
|
case PrintInstMode::NUM: |
80 |
|
return os << "PrintInstMode::NUM"; |
81 |
|
case PrintInstMode::LIST: |
82 |
|
return os << "PrintInstMode::LIST"; |
83 |
|
default: |
84 |
|
Unreachable(); |
85 |
|
} |
86 |
|
return os; |
87 |
|
} |
88 |
|
|
89 |
3 |
PrintInstMode stringToPrintInstMode(const std::string& optarg) |
90 |
|
{ |
91 |
3 |
if (optarg == "num") |
92 |
|
{ |
93 |
3 |
return PrintInstMode::NUM; |
94 |
|
} |
95 |
|
else if (optarg == "list") |
96 |
|
{ |
97 |
|
return PrintInstMode::LIST; |
98 |
|
} |
99 |
|
else if (optarg == "help") |
100 |
|
{ |
101 |
|
std::cerr << "Print format for printing instantiations.\n" |
102 |
|
"Available modes for --print-inst are:\n" |
103 |
|
"+ num\n" |
104 |
|
" Print the total number of instantiations per quantified formula, when\n" |
105 |
|
" non-zero.\n" |
106 |
|
"+ list (default)\n" |
107 |
|
" Print the list of instantiations per quantified formula, when non-empty.\n"; |
108 |
|
std::exit(1); |
109 |
|
} |
110 |
|
throw OptionException(std::string("unknown option for --print-inst: `") + |
111 |
|
optarg + "'. Try --print-inst=help."); |
112 |
|
} |
113 |
|
|
114 |
|
|
115 |
|
|
116 |
|
namespace printer |
117 |
|
{ |
118 |
|
// clang-format off |
119 |
|
void setDefaultFlattenHOChains(Options& opts, bool value) |
120 |
|
{ |
121 |
|
if (!opts.printer.flattenHOChainsWasSetByUser) { |
122 |
|
opts.printer.flattenHOChains = value; |
123 |
|
} |
124 |
|
} |
125 |
|
void setDefaultInstFormatMode(Options& opts, InstFormatMode value) |
126 |
|
{ |
127 |
|
if (!opts.printer.instFormatModeWasSetByUser) { |
128 |
|
opts.printer.instFormatMode = value; |
129 |
|
} |
130 |
|
} |
131 |
|
void setDefaultModelFormatMode(Options& opts, ModelFormatMode value) |
132 |
|
{ |
133 |
|
if (!opts.printer.modelFormatModeWasSetByUser) { |
134 |
|
opts.printer.modelFormatMode = value; |
135 |
|
} |
136 |
|
} |
137 |
|
void setDefaultPrintInstFull(Options& opts, bool value) |
138 |
|
{ |
139 |
|
if (!opts.printer.printInstFullWasSetByUser) { |
140 |
|
opts.printer.printInstFull = value; |
141 |
|
} |
142 |
|
} |
143 |
|
void setDefaultPrintInstMode(Options& opts, PrintInstMode value) |
144 |
|
{ |
145 |
|
if (!opts.printer.printInstModeWasSetByUser) { |
146 |
|
opts.printer.printInstMode = value; |
147 |
|
} |
148 |
|
} |
149 |
|
// clang-format on |
150 |
|
} |
151 |
|
|
152 |
|
} // namespace options |
153 |
29286 |
} // namespace cvc5 |
154 |
|
// clang-format on |