fix(frontends/lean/parse_rewrite_tactic): corner case "rewrite ?(t)"
The token '?(' is used to represent inaccessible terms in recursive equations. In the rewriter tactic, we want "rewrite ?(t)" to be parsed as "? (t)".
This commit is contained in:
parent
991d29b7f6
commit
8912c759dd
3 changed files with 17 additions and 0 deletions
|
@ -52,6 +52,12 @@ expr parse_rewrite_element(parser & p) {
|
|||
expr H = parse_rule(p);
|
||||
location loc = parse_tactic_location(p);
|
||||
return mk_rewrite_at_most_n(pat, H, symm, n, loc);
|
||||
} else if (p.curr_is_token(get_question_lp_tk())) {
|
||||
p.next();
|
||||
expr H = p.parse_expr();
|
||||
p.check_token_next(get_rparen_tk(), "invalid rewrite pattern, ')' expected");
|
||||
location loc = parse_tactic_location(p);
|
||||
return mk_rewrite_at_most_n(optional<expr>(), H, symm, n, loc);
|
||||
} else if (p.curr_is_token(get_bang_tk())) {
|
||||
p.next();
|
||||
optional<expr> pat = parse_pattern(p);
|
||||
|
@ -70,6 +76,12 @@ expr parse_rewrite_element(parser & p) {
|
|||
expr H = parse_rule(p);
|
||||
location loc = parse_tactic_location(p);
|
||||
return mk_rewrite_zero_or_more(pat, H, symm, loc);
|
||||
} else if (p.curr_is_token(get_question_lp_tk())) {
|
||||
p.next();
|
||||
expr H = p.parse_expr();
|
||||
p.check_token_next(get_rparen_tk(), "invalid rewrite pattern, ')' expected");
|
||||
location loc = parse_tactic_location(p);
|
||||
return mk_rewrite_zero_or_more(optional<expr>(), H, symm, loc);
|
||||
} else if (p.curr_is_token(get_bang_tk())) {
|
||||
p.next();
|
||||
optional<expr> pat = parse_pattern(p);
|
||||
|
|
|
@ -27,6 +27,7 @@ static name * g_comma = nullptr;
|
|||
static name * g_add = nullptr;
|
||||
static name * g_sub = nullptr;
|
||||
static name * g_question = nullptr;
|
||||
static name * g_question_lp = nullptr;
|
||||
static name * g_bang = nullptr;
|
||||
static name * g_slash = nullptr;
|
||||
static name * g_star = nullptr;
|
||||
|
@ -133,6 +134,7 @@ void initialize_tokens() {
|
|||
g_add = new name("+");
|
||||
g_sub = new name("-");
|
||||
g_question = new name("?");
|
||||
g_question_lp = new name("?(");
|
||||
g_bang = new name("!");
|
||||
g_slash = new name("/");
|
||||
g_star = new name("*");
|
||||
|
@ -303,6 +305,7 @@ void finalize_tokens() {
|
|||
delete g_add;
|
||||
delete g_sub;
|
||||
delete g_question;
|
||||
delete g_question_lp;
|
||||
delete g_bang;
|
||||
delete g_slash;
|
||||
delete g_star;
|
||||
|
@ -346,6 +349,7 @@ name const & get_comma_tk() { return *g_comma; }
|
|||
name const & get_add_tk() { return *g_add; }
|
||||
name const & get_sub_tk() { return *g_sub; }
|
||||
name const & get_question_tk() { return *g_question; }
|
||||
name const & get_question_lp_tk() { return *g_question_lp; }
|
||||
name const & get_bang_tk() { return *g_bang; }
|
||||
name const & get_slash_tk() { return *g_slash; }
|
||||
name const & get_star_tk() { return *g_star; }
|
||||
|
|
|
@ -29,6 +29,7 @@ name const & get_comma_tk();
|
|||
name const & get_add_tk();
|
||||
name const & get_sub_tk();
|
||||
name const & get_question_tk();
|
||||
name const & get_question_lp_tk();
|
||||
name const & get_bang_tk();
|
||||
name const & get_slash_tk();
|
||||
name const & get_star_tk();
|
||||
|
|
Loading…
Reference in a new issue