Parser *parser =
d_parserBuilder
.withStringInput(input)
+ .withStateFrom(d_lastParser)
.build();
/* There may be more than one command in the input. Build up a
cmd_seq->addCommand(cmd);
}
- delete parser;
+ delete d_lastParser;
+ d_lastParser = parser;
+
return cmd_seq;
}
using namespace parser;
-class InteractiveShell {
+class CVC4_PUBLIC InteractiveShell {
std::istream& d_in;
std::ostream& d_out;
ParserBuilder d_parserBuilder;
+ Parser* d_lastParser;
public:
InteractiveShell(ParserBuilder& parserBuilder,
const Options& options) :
d_in(*options.in),
d_out(*options.out),
- d_parserBuilder(parserBuilder) {
+ d_parserBuilder(parserBuilder),
+ d_lastParser(NULL) {
}
/** Read a command from the interactive shell. This will read as
d_filename = filename;
d_streamInput = NULL;
d_exprManager = exprManager;
+ d_parserToUseForState = NULL;
d_checksEnabled = true;
d_strictMode = false;
d_mmap = false;
parser->disableChecks();
}
+ if( d_parserToUseForState != NULL ) {
+ parser->d_declScope = d_parserToUseForState->d_declScope;
+ parser->d_logicOperators = d_parserToUseForState->d_logicOperators;
+ }
+
return parser;
}
.withStrictMode(options.strictParsing);
}
+ParserBuilder& ParserBuilder::withStateFrom(const Parser* parser) {
+ d_parserToUseForState = parser;
+ return *this;
+}
+
ParserBuilder& ParserBuilder::withStrictMode(bool flag) {
d_strictMode = flag;
return *this;
/** The expression manager */
ExprManager& d_exprManager;
+ /** Parser to derive the initial state from. */
+ const Parser* d_parserToUseForState;
+
/** Should semantic checks be enabled during parsing? */
bool d_checksEnabled;
/** Derive settings from the given options. */
ParserBuilder& withOptions(const Options& options);
+ /** Copy the state (e.g., variable and type declaration) from
+ * an existing parser. If <code>parser</code> is <code>NULL</code>,
+ * the default initial state will be used. */
+ ParserBuilder& withStateFrom(const Parser* parser);
+
/** Should the parser use strict mode? (Default: no) */
ParserBuilder& withStrictMode(bool flag = true);