feat(frontends/lean/parser): save snapshots

Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
This commit is contained in:
Leonardo de Moura 2014-08-06 18:31:53 -07:00
parent 9b765a2a06
commit 1ba9a92df2
2 changed files with 9 additions and 0 deletions

View file

@ -1136,6 +1136,7 @@ bool parser::parse_commands() {
switch (curr()) { switch (curr()) {
case scanner::token_kind::CommandKeyword: case scanner::token_kind::CommandKeyword:
parse_command(); parse_command();
save_snapshot();
break; break;
case scanner::token_kind::ScriptBlock: case scanner::token_kind::ScriptBlock:
parse_script(); parse_script();
@ -1165,6 +1166,13 @@ void parser::add_delayed_theorem(environment const & env, name const & n, level_
m_theorem_queue.add(env, n, ls, get_local_level_decls(), t, v); m_theorem_queue.add(env, n, ls, get_local_level_decls(), t, v);
} }
void parser::save_snapshot() {
if (!m_snapshot_vector)
return;
if (m_snapshot_vector->empty() || static_cast<int>(m_snapshot_vector->back().m_line) != m_scanner.get_line())
m_snapshot_vector->push_back(snapshot(m_env, m_local_level_decls, m_local_decls, m_ios.get_options(), m_scanner.get_line()));
}
bool parse_commands(environment & env, io_state & ios, std::istream & in, char const * strm_name, bool use_exceptions, bool parse_commands(environment & env, io_state & ios, std::istream & in, char const * strm_name, bool use_exceptions,
unsigned num_threads) { unsigned num_threads) {
parser p(env, ios, in, strm_name, use_exceptions, num_threads); parser p(env, ios, in, strm_name, use_exceptions, num_threads);

View file

@ -151,6 +151,7 @@ class parser {
void push_local_scope(); void push_local_scope();
void pop_local_scope(); void pop_local_scope();
void save_snapshot();
public: public:
parser(environment const & env, io_state const & ios, parser(environment const & env, io_state const & ios,