3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-04-08 18:31:49 +00:00

Added (include ...) SMT2 command.

This commit is contained in:
Christoph M. Wintersteiger 2017-01-16 15:05:58 +00:00
parent 6fe1682378
commit 00a50eea7f
3 changed files with 75 additions and 0 deletions

View file

@ -29,6 +29,7 @@ Revision History:
#include"opt_cmds.h"
#include"polynomial_cmds.h"
#include"subpaving_cmds.h"
#include"smt2_extra_cmds.h"
#include"smt_strategic_solver.h"
#include"smt_solver.h"
@ -113,6 +114,7 @@ unsigned read_smtlib2_commands(char const * file_name) {
install_polynomial_cmds(ctx);
install_subpaving_cmds(ctx);
install_opt_cmds(ctx);
install_smt2_extra_cmds(ctx);
g_cmd_context = &ctx;
signal(SIGINT, on_ctrl_c);

View file

@ -0,0 +1,47 @@
/*++
Copyright (c) 2011 Microsoft Corporation
Module Name:
smt2_extra_cmds.cpp
Abstract:
Additional SMT-specific commands.
Author:
Christoph (cwinter) 2017-01-16
Notes:
--*/
#include"cmd_context.h"
#include"smt2parser.h"
#include"smt2_extra_cmds.h"
class include_cmd : public cmd {
char const * m_filename;
public:
include_cmd() : cmd("include"), m_filename(0) {}
virtual char const * get_usage() const { return "<string>"; }
virtual char const * get_descr(cmd_context & ctx) const { return "include a file"; }
virtual unsigned get_arity() const { return 1; }
virtual cmd_arg_kind next_arg_kind(cmd_context & ctx) const { return CPK_STRING; }
virtual void set_next_arg(cmd_context & ctx, char const * val) { m_filename = val; }
virtual void failure_cleanup(cmd_context & ctx) {}
virtual void execute(cmd_context & ctx) {
std::ifstream is(m_filename);
if (is.bad() || is.fail())
throw cmd_exception(std::string("failed to open file '") + m_filename + "'");
parse_smt2_commands(ctx, is, false);
is.close();
}
virtual void prepare(cmd_context & ctx) { reset(ctx); }
virtual void reset(cmd_context & ctx) { m_filename = 0; }
virtual void finalize(cmd_context & ctx) { reset(ctx); }
};
void install_smt2_extra_cmds(cmd_context & ctx) {
ctx.insert(alloc(include_cmd));
}

26
src/smt/smt2_extra_cmds.h Normal file
View file

@ -0,0 +1,26 @@
/*++
Copyright (c) 2011 Microsoft Corporation
Module Name:
smt2_extra_cmds.h
Abstract:
Additional SMT-specific commands.
Author:
Christoph (cwinter) 2017-01-16
Notes:
--*/
#ifndef SMT2_EXTRA_CMDS_H_
#define SMT2_EXTRA_CMDS_H_
class cmd_context;
void install_smt2_extra_cmds(cmd_context & ctx);
#endif /* SMT2_EXTRA_CMDS_H_ */