#endif /* HAVE_LIBREADLINE */
-InteractiveShell::InteractiveShell(ExprManager& exprManager,
- const Options& options)
- : d_in(*options.getIn()),
- d_out(*options.getOutConst()),
- d_options(options),
+InteractiveShell::InteractiveShell(ExprManager& exprManager)
+ : d_options(exprManager.getOptions()),
+ d_in(*d_options.getIn()),
+ d_out(*d_options.getOutConst()),
d_quit(false)
{
- ParserBuilder parserBuilder(&exprManager, INPUT_FILENAME, options);
+ ParserBuilder parserBuilder(&exprManager, INPUT_FILENAME, d_options);
/* Create parser with bogus input. */
d_parser = parserBuilder.withStringInput("").build();
if(d_options.wasSetByUserForceLogicString()) {
/*! \file interactive_shell.h
** \verbatim
** Top contributors (to current version):
- ** Morgan Deters, Christopher L. Conway, Tim King
+ ** Morgan Deters, Christopher L. Conway, Aina Niemetz
** This file is part of the CVC4 project.
** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS
** in the top-level source directory) and their institutional affiliations.
class Parser;
}/* CVC4::parser namespace */
-class CVC4_PUBLIC InteractiveShell {
+class CVC4_PUBLIC InteractiveShell
+{
+ const Options& d_options;
std::istream& d_in;
std::ostream& d_out;
parser::Parser* d_parser;
- const Options& d_options;
bool d_quit;
bool d_usingReadline;
static const unsigned s_historyLimit = 500;
public:
- InteractiveShell(ExprManager& exprManager, const Options& options);
-
- /**
- * Close out the interactive session.
- */
- ~InteractiveShell();
-
- /**
- * Read a command from the interactive shell. This will read as
- * many lines as necessary to parse a well-formed command.
- */
- Command* readCommand();
-
- /**
- * Return the internal parser being used.
- */
- parser::Parser* getParser() {
- return d_parser;
- }
+ InteractiveShell(ExprManager& exprManager);
+
+ /**
+ * Close out the interactive session.
+ */
+ ~InteractiveShell();
+
+ /**
+ * Read a command from the interactive shell. This will read as
+ * many lines as necessary to parse a well-formed command.
+ */
+ Command* readCommand();
+
+ /**
+ * Return the internal parser being used.
+ */
+ parser::Parser* getParser() { return d_parser; }
};/* class InteractiveShell */
stringstream* d_sin;
stringstream* d_sout;
- /** Read up to maxCommands+1 from the shell and throw an assertion
- error if it's fewer than minCommands and more than maxCommands.
- Note that an empty string followed by EOF may be returned as an
- empty command, and not NULL (subsequent calls to readCommand()
- should return NULL). E.g., "CHECKSAT;\n" may return two
- commands: the CHECKSAT, followed by an empty command, followed
- by NULL. */
+ /**
+ * Read up to maxCommands+1 from the shell and throw an assertion error if
+ * it's fewer than minCommands and more than maxCommands.
+ * Note that an empty string followed by EOF may be returned as an empty
+ * command, and not NULL (subsequent calls to readCommand() should return
+ * NULL). E.g., "CHECKSAT;\n" may return two commands: the CHECKSAT,
+ * followed by an empty command, followed by NULL.
+ */
void countCommands(InteractiveShell& shell,
int minCommands,
int maxCommands) {
public:
void setUp() {
- d_exprManager = new ExprManager;
d_sin = new stringstream;
d_sout = new stringstream;
d_options.set(options::in, d_sin);
d_options.set(options::out, d_sout);
d_options.set(options::inputLanguage, language::input::LANG_CVC4);
+ d_exprManager = new ExprManager(d_options);
}
void tearDown() {
void testAssertTrue() {
*d_sin << "ASSERT TRUE;\n" << flush;
- InteractiveShell shell(*d_exprManager, d_options);
+ InteractiveShell shell(*d_exprManager);
countCommands( shell, 1, 1 );
}
void testQueryFalse() {
*d_sin << "QUERY FALSE;\n" << flush;
- InteractiveShell shell(*d_exprManager, d_options);
+ InteractiveShell shell(*d_exprManager);
countCommands( shell, 1, 1 );
}
void testDefUse() {
- InteractiveShell shell(*d_exprManager, d_options);
+ InteractiveShell shell(*d_exprManager);
*d_sin << "x : REAL; ASSERT x > 0;\n" << flush;
/* readCommand may return a sequence, so we can't say for sure
whether it will return 1 or 2... */
}
void testDefUse2() {
- InteractiveShell shell(*d_exprManager, d_options);
+ InteractiveShell shell(*d_exprManager);
/* readCommand may return a sequence, see above. */
*d_sin << "x : REAL;\n" << flush;
Command* tmp = shell.readCommand();
}
void testEmptyLine() {
- InteractiveShell shell(*d_exprManager, d_options);
+ InteractiveShell shell(*d_exprManager);
*d_sin << flush;
countCommands(shell,0,0);
}
void testRepeatedEmptyLines() {
*d_sin << "\n\n\n";
- InteractiveShell shell(*d_exprManager, d_options);
+ InteractiveShell shell(*d_exprManager);
/* Might return up to four empties, might return nothing */
countCommands( shell, 0, 3 );
}