1 |
|
/****************************************************************************** |
2 |
|
* Top contributors (to current version): |
3 |
|
* Tim King, 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 |
|
* Interface for custom handlers and predicates options. |
14 |
|
*/ |
15 |
|
|
16 |
|
#include "cvc5_private.h" |
17 |
|
|
18 |
|
#ifndef CVC5__OPTIONS__OPTIONS_HANDLER_H |
19 |
|
#define CVC5__OPTIONS__OPTIONS_HANDLER_H |
20 |
|
|
21 |
|
#include <ostream> |
22 |
|
#include <sstream> |
23 |
|
#include <string> |
24 |
|
|
25 |
|
#include "options/bv_options.h" |
26 |
|
#include "options/decision_options.h" |
27 |
|
#include "options/language.h" |
28 |
|
#include "options/managed_streams.h" |
29 |
|
#include "options/option_exception.h" |
30 |
|
#include "options/quantifiers_options.h" |
31 |
|
|
32 |
|
namespace cvc5 { |
33 |
|
|
34 |
|
class Options; |
35 |
|
|
36 |
|
namespace options { |
37 |
|
|
38 |
|
/** |
39 |
|
* Class that responds to command line options being set. |
40 |
|
* |
41 |
|
* Most functions can throw an OptionException on failure. |
42 |
|
*/ |
43 |
|
class OptionsHandler |
44 |
|
{ |
45 |
|
public: |
46 |
|
OptionsHandler(Options* options); |
47 |
|
|
48 |
|
template <typename T> |
49 |
3 |
void checkMinimum(const std::string& flag, T value, T minimum) const |
50 |
|
{ |
51 |
3 |
if (value < minimum) |
52 |
|
{ |
53 |
|
std::stringstream ss; |
54 |
|
ss << flag << " = " << value |
55 |
|
<< " is not a legal setting, value should be at least " << minimum |
56 |
|
<< "."; |
57 |
|
throw OptionException(ss.str()); |
58 |
|
} |
59 |
3 |
} |
60 |
|
template <typename T> |
61 |
2 |
void checkMaximum(const std::string& flag, T value, T maximum) const |
62 |
|
{ |
63 |
2 |
if (value > maximum) |
64 |
|
{ |
65 |
|
std::stringstream ss; |
66 |
|
ss << flag << " = " << value |
67 |
|
<< " is not a legal setting, value should be at most " << maximum |
68 |
|
<< "."; |
69 |
|
throw OptionException(ss.str()); |
70 |
|
} |
71 |
2 |
} |
72 |
|
|
73 |
|
/******************************* base options *******************************/ |
74 |
|
/** Apply the error output stream to the different output channels */ |
75 |
|
void setErrStream(const std::string& flag, const ManagedErr& me); |
76 |
|
|
77 |
|
/** Convert option value to Language enum */ |
78 |
|
Language stringToLanguage(const std::string& flag, const std::string& optarg); |
79 |
|
/** Check that lang is not LANG_AST (not allowed as input language) */ |
80 |
|
void languageIsNotAST(const std::string& flag, Language lang); |
81 |
|
/** Apply the output language to the default output stream */ |
82 |
|
void applyOutputLanguage(const std::string& flag, Language lang); |
83 |
|
/** Apply verbosity to the different output channels */ |
84 |
|
void setVerbosity(const std::string& flag, int value); |
85 |
|
/** Decrease verbosity and call setVerbosity */ |
86 |
|
void decreaseVerbosity(const std::string& flag); |
87 |
|
/** Increase verbosity and call setVerbosity */ |
88 |
|
void increaseVerbosity(const std::string& flag); |
89 |
|
/** If statistics are disabled, disable statistics sub-options */ |
90 |
|
void setStats(const std::string& flag, bool value); |
91 |
|
/** If statistics sub-option is disabled, enable statistics */ |
92 |
|
void setStatsDetail(const std::string& flag, bool value); |
93 |
|
/** Enable a particular trace tag */ |
94 |
|
void enableTraceTag(const std::string& flag, const std::string& optarg); |
95 |
|
/** Enable a particular debug tag */ |
96 |
|
void enableDebugTag(const std::string& flag, const std::string& optarg); |
97 |
|
/** Enable a particular output tag */ |
98 |
|
void enableOutputTag(const std::string& flag, const std::string& optarg); |
99 |
|
/** Apply print success flag to the different output channels */ |
100 |
|
void setPrintSuccess(const std::string& flag, bool value); |
101 |
|
/** Pass the resource weight specification to the resource manager */ |
102 |
|
void setResourceWeight(const std::string& flag, const std::string& optarg); |
103 |
|
|
104 |
|
/******************************* bv options *******************************/ |
105 |
|
|
106 |
|
/** Check that abc is enabled */ |
107 |
|
void abcEnabledBuild(const std::string& flag, bool value); |
108 |
|
/** Check that abc is enabled */ |
109 |
|
void abcEnabledBuild(const std::string& flag, const std::string& value); |
110 |
|
/** Check that the sat solver mode is compatible with other bv options */ |
111 |
|
void checkBvSatSolver(const std::string& flag, SatSolverMode m); |
112 |
|
/** Check that we use eager bitblasting for aig */ |
113 |
|
void setBitblastAig(const std::string& flag, bool arg); |
114 |
|
|
115 |
|
/******************************* expr options *******************************/ |
116 |
|
/** Set ExprSetDepth on all output streams */ |
117 |
|
void setDefaultExprDepth(const std::string& flag, int depth); |
118 |
|
/** Set ExprDag on all output streams */ |
119 |
|
void setDefaultDagThresh(const std::string& flag, int dag); |
120 |
|
|
121 |
|
/******************************* main options *******************************/ |
122 |
|
/** Show the solver build configuration and exit */ |
123 |
|
void showConfiguration(const std::string& flag); |
124 |
|
/** Show copyright information and exit */ |
125 |
|
void showCopyright(const std::string& flag); |
126 |
|
/** Show version information and exit */ |
127 |
|
void showVersion(const std::string& flag); |
128 |
|
/** Show all debug tags and exit */ |
129 |
|
void showDebugTags(const std::string& flag); |
130 |
|
/** Show all trace tags and exit */ |
131 |
|
void showTraceTags(const std::string& flag); |
132 |
|
|
133 |
|
private: |
134 |
|
/** Pointer to the containing Options object.*/ |
135 |
|
Options* d_options; |
136 |
|
}; /* class OptionHandler */ |
137 |
|
|
138 |
|
} // namespace options |
139 |
|
} // namespace cvc5 |
140 |
|
|
141 |
|
#endif /* CVC5__OPTIONS__OPTIONS_HANDLER_H */ |