feat(frontends/lean/parse_rewrite_tactic): accept trailing comman in rewrite tactic

see issue #695
This commit is contained in:
Leonardo de Moura 2015-06-28 11:45:30 -07:00
parent 4a4ef48344
commit d1eaa7bcda
2 changed files with 9 additions and 2 deletions

View file

@ -135,14 +135,14 @@ static expr parse_rewrite_element(parser & p, bool use_paren) {
void parse_rewrite_tactic_elems(parser & p, buffer<expr> & elems) {
if (p.curr_is_token(get_lbracket_tk())) {
p.next();
while (true) {
while (!p.curr_is_token(get_rbracket_tk())) {
auto pos = p.pos();
elems.push_back(p.save_pos(parse_rewrite_element(p, false), pos));
if (!p.curr_is_token(get_comma_tk()))
break;
p.next();
}
p.check_token_next(get_rbracket_tk(), "invalid rewrite tactic, ',' or ']' expected");
p.next();
} else {
auto pos = p.pos();
elems.push_back(p.save_pos(parse_rewrite_element(p, true), pos));

7
tests/lean/run/695d.lean Normal file
View file

@ -0,0 +1,7 @@
import data.nat
open nat
example (a b : nat) : 0 + a + 0 = a :=
begin
rewrite [add_zero, zero_add,]
end