feat(frontends/lean/builtin_exprs): parse '_' placeholder

Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
This commit is contained in:
Leonardo de Moura 2014-06-16 10:41:08 -07:00
parent 249168ce0b
commit 6db265e7ab
3 changed files with 9 additions and 1 deletions

View file

@ -85,6 +85,10 @@ static expr parse_let_expr(parser & p, unsigned, expr const *) {
return parse_let(p);
}
static expr parse_placeholder(parser &, unsigned, expr const *) {
return mk_expr_placeholder();
}
parse_table init_nud_table() {
action Expr(mk_expr_action());
action Skip(mk_skip_action());
@ -92,6 +96,7 @@ parse_table init_nud_table() {
expr x0 = mk_var(0);
parse_table r;
r = r.add({transition("Bool", Skip)}, mk_Bool());
r = r.add({transition("_", mk_ext_action(parse_placeholder))}, x0);
r = r.add({transition("(", Expr), transition(")", Skip)}, x0);
r = r.add({transition("fun", Binders), transition(",", mk_scoped_expr_action(x0))}, x0);
r = r.add({transition("Pi", Binders), transition(",", mk_scoped_expr_action(x0, 0, false))}, x0);

View file

@ -55,7 +55,7 @@ token_table init_token_table() {
token_table t;
std::pair<char const *, unsigned> builtin[] =
{{"fun", 0}, {"Pi", 0}, {"let", 0}, {"in", 0}, {"have", 0}, {"show", 0}, {"by", 0},
{"from", 0}, {"(", g_max_prec}, {")", 0}, {"{", g_max_prec}, {"}", 0},
{"from", 0}, {"(", g_max_prec}, {")", 0}, {"{", g_max_prec}, {"}", 0}, {"_", g_max_prec},
{"[", g_max_prec}, {"]", 0}, {".{", 0}, {"Type", g_max_prec},
{"...", 0}, {",", 0}, {".", 0}, {":", 0}, {"calc", 0}, {":=", 0}, {"--", 0},
{"(*", 0}, {"(--", 0}, {"proof", 0}, {"qed", 0}, {"raw", 0}, {"Bool", g_max_prec},

3
tests/lean/run/t7.lean Normal file
View file

@ -0,0 +1,3 @@
variable A : Type.{1}
variable f : A → A → A
print raw f _ (f _ _)