feat: add evalChoice

cc @Kha
This commit is contained in:
Leonardo de Moura 2020-02-18 13:53:18 -08:00
parent 5a44227f73
commit 412c3f5978
2 changed files with 42 additions and 0 deletions

View file

@ -297,6 +297,21 @@ match newGoals with
@[builtinTactic seq] def evalSeq : Tactic :=
fun stx => (stx.getArg 0).forSepArgsM evalTactic
partial def evalChoiceAux (tactics : Array Syntax) : Nat → TacticM Unit
| i =>
if h : i < tactics.size then
let tactic := tactics.get ⟨i, h⟩;
catch
(evalTactic tactic)
(fun ex => match ex with
| Exception.unsupportedSyntax => evalChoiceAux (i+1)
| _ => throw ex)
else
throwUnsupportedSyntax
@[builtinTactic choice] def evalChoice : Tactic :=
fun stx => evalChoiceAux stx.getArgs 0
@[builtinTactic skip] def evalSkip : Tactic :=
fun stx => pure ()

View file

@ -0,0 +1,27 @@
new_frontend
open Lean
syntax [myintro] "intros" (sepBy ident ",") : tactic
macro_rules [myintro]
| `(tactic| intros $x*) => pure $ Syntax.node `Lean.Parser.Tactic.intros #[Syntax.atom none "intros", mkNullNode x.getSepElems]
theorem tst1 {p q : Prop} : p → q → p :=
begin
intros h1, h2;
assumption
end
theorem tst2 {p q : Prop} : p → q → p :=
begin
intros h1; -- the builtin and myintro overlap here.
intros h2; -- the builtin and myintro overlap here.
assumption
end
theorem tst3 {p q : Prop} : p → q → p :=
begin
intros h1 h2;
assumption
end