3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-04-26 02:25:32 +00:00

working on new parameter framework

Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
This commit is contained in:
Leonardo de Moura 2012-12-01 15:54:34 -08:00
parent be5f933201
commit 589f096e6e
36 changed files with 436 additions and 377 deletions

View file

@ -28,6 +28,8 @@ Revision History:
#include"solver.h"
#include"smt_strategic_solver.h"
#include"cmd_context.h"
#include"model_params.hpp"
#include"parser_params.hpp"
namespace smtlib {
@ -35,8 +37,9 @@ namespace smtlib {
m_ast_manager(params.m_proof_mode, params.m_trace_stream),
m_params(params),
m_ctx(0),
m_parser(parser::create(m_ast_manager, params.m_ignore_user_patterns)),
m_error_code(0) {
parser_params ps;
m_parser = parser::create(m_ast_manager, ps.ignore_user_patterns());
m_parser->initialize_smtlib();
}
@ -82,7 +85,7 @@ namespace smtlib {
// Hack: it seems SMT-LIB allow benchmarks without any :formula
benchmark.add_formula(m_ast_manager.mk_true());
}
m_ctx = alloc(cmd_context, &m_params, true, &m_ast_manager, benchmark.get_logic());
m_ctx = alloc(cmd_context, true, &m_ast_manager, benchmark.get_logic());
m_ctx->set_solver(mk_smt_strategic_solver(false));
theory::expr_iterator fit = benchmark.begin_formulas();
theory::expr_iterator fend = benchmark.end_formulas();
@ -105,7 +108,8 @@ namespace smtlib {
model_ref md;
if (r->status() != l_false) r->get_model(md);
if (md.get() != 0 && m_params.m_model) {
model_v2_pp(std::cout, *(md.get()), m_params.m_model_partial);
model_params p;
model_v2_pp(std::cout, *(md.get()), p.partial());
}
}
else {

View file

@ -28,7 +28,7 @@ Revision History:
#include"rewriter.h"
#include"has_free_vars.h"
#include"ast_smt2_pp.h"
#include"front_end_params.h"
#include"parser_params.hpp"
namespace smt2 {
typedef cmd_exception parser_exception;
@ -106,9 +106,14 @@ namespace smt2 {
ast_manager & m() const { return m_ctx.m(); }
pdecl_manager & pm() const { return m_ctx.pm(); }
sexpr_manager & sm() const { return m_ctx.sm(); }
bool m_ignore_user_patterns;
bool m_ignore_bad_patterns;
bool m_display_error_for_vs;
bool ignore_user_patterns() const { return m_ctx.params().m_ignore_user_patterns; }
bool ignore_bad_patterns() const { return m_ctx.params().m_ignore_bad_patterns; }
bool ignore_user_patterns() const { return m_ignore_user_patterns; }
bool ignore_bad_patterns() const { return m_ignore_bad_patterns; }
bool use_vs_format() const { return m_display_error_for_vs; }
struct psort_frame {
psort_decl * m_decl;
@ -383,8 +388,6 @@ namespace smt2 {
void check_int(char const * msg) { if (!curr_is_int()) throw parser_exception(msg); }
void check_float(char const * msg) { if (!curr_is_float()) throw parser_exception(msg); }
bool use_vs_format() const { return m_ctx.params().m_display_error_for_vs; }
void error(unsigned line, unsigned pos, char const * msg) {
if (use_vs_format()) {
m_ctx.diagnostic_stream() << "Z3(" << line << ", " << pos << "): ERROR: " << msg;
@ -2354,9 +2357,9 @@ namespace smt2 {
}
public:
parser(cmd_context & ctx, std::istream & is, bool interactive):
parser(cmd_context & ctx, std::istream & is, bool interactive, params_ref const & _p):
m_ctx(ctx),
m_scanner(ctx, is, interactive),
m_scanner(ctx, is, interactive, _p),
m_curr(scanner::NULL_TOKEN),
m_curr_cmd(0),
m_num_bindings(0),
@ -2393,6 +2396,11 @@ namespace smt2 {
m_num_open_paren(0) {
// the following assertion does not hold if ctx was already attached to an AST manager before the parser object is created.
// SASSERT(!m_ctx.has_manager());
parser_params p(_p);
m_ignore_user_patterns = p.ignore_user_patterns();
m_ignore_bad_patterns = p.ignore_bad_patterns();
m_display_error_for_vs = p.error_for_visual_studio();
}
~parser() {
@ -2487,8 +2495,8 @@ namespace smt2 {
};
};
bool parse_smt2_commands(cmd_context & ctx, std::istream & is, bool interactive) {
smt2::parser p(ctx, is, interactive);
bool parse_smt2_commands(cmd_context & ctx, std::istream & is, bool interactive, params_ref const & ps) {
smt2::parser p(ctx, is, interactive, ps);
return p();
}

View file

@ -21,6 +21,6 @@ Revision History:
#include"cmd_context.h"
bool parse_smt2_commands(cmd_context & ctx, std::istream & is, bool interactive = false);
bool parse_smt2_commands(cmd_context & ctx, std::istream & is, bool interactive = false, params_ref const & p = params_ref());
#endif

View file

@ -17,6 +17,7 @@ Revision History:
--*/
#include"smt2scanner.h"
#include"parser_params.hpp"
namespace smt2 {
@ -241,7 +242,7 @@ namespace smt2 {
}
}
scanner::scanner(cmd_context & ctx, std::istream& stream, bool interactive):
scanner::scanner(cmd_context & ctx, std::istream& stream, bool interactive, params_ref const & _p):
m_ctx(ctx),
m_interactive(interactive),
m_spos(0),
@ -253,6 +254,10 @@ namespace smt2 {
m_bend(0),
m_stream(stream),
m_cache_input(false) {
parser_params p(_p);
m_smtlib2_compliant = p.smt2_compliant();
for (int i = 0; i < 256; ++i) {
m_normalized[i] = (char) i;
}
@ -325,7 +330,7 @@ namespace smt2 {
case '#':
return read_bv_literal();
case '-':
if (m_ctx.is_smtlib2_compliant())
if (m_smtlib2_compliant)
return read_symbol();
else
return read_signed_number();

View file

@ -55,6 +55,8 @@ namespace smt2 {
svector<char> m_cache;
svector<char> m_cache_result;
bool m_smtlib2_compliant;
char curr() const { return m_curr; }
void new_line() { m_line++; m_spos = 0; }
void next();
@ -74,7 +76,7 @@ namespace smt2 {
EOF_TOKEN
};
scanner(cmd_context & ctx, std::istream& stream, bool interactive = false);
scanner(cmd_context & ctx, std::istream& stream, bool interactive = false, params_ref const & p = params_ref());
~scanner() {}

View file

@ -0,0 +1,6 @@
def_module_params('parser',
export=True,
params=(('ignore_user_patterns', BOOL, False, 'ignore patterns provided by the user'),
('ignore_bad_patterns', BOOL, True, 'ignore malformed patterns'),
('error_for_visual_studio', BOOL, False, 'display error messages in Visual Studio format'),
('smt2_compliant', BOOL, False, 'enable/disable SMT-LIB 2.0 compliance')))