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