feat(frontends/lean/builtin_exprs): better error synchronization for 'begin...end' blocks

This commit is contained in:
Leonardo de Moura 2015-03-13 15:22:57 -07:00
parent aba158dbd4
commit 9438366e37

View file

@ -147,6 +147,7 @@ static expr parse_begin_end_core(parser & p, pos_info const & pos, name const &
tacs.push_back(tac);
};
try {
while (!p.curr_is_token(end_token)) {
if (first) {
first = false;
@ -240,6 +241,20 @@ static expr parse_begin_end_core(parser & p, pos_info const & pos, name const &
add_tac(t, pos);
}
}
} catch (exception & ex) {
if (end_token == get_end_tk()) {
// When the end_token is 'end', the default parser
// sync_command does not work well because it will
// interpret 'end' as a synchronization point because 'end' is also a command.
while (!p.curr_is_token(get_end_tk())) {
if (p.curr() == scanner::token_kind::Eof)
ex.rethrow();
p.next();
}
p.next(); // consume 'end'
}
ex.rethrow();
}
auto end_pos = p.pos();
p.next();
if (tacs.empty()) {