feat: FFI interface for `evaluate` tactic

This commit is contained in:
Leni Aniva 2024-06-25 17:01:49 -04:00
parent 7acf1ffdf1
commit 2d2ff24017
Signed by: aniva
GPG Key ID: 4D9B1C8D10EA4C50
2 changed files with 10 additions and 2 deletions

View File

@ -186,7 +186,15 @@ protected def GoalState.tryHave (state: GoalState) (goalId: Nat) (binderName: St
| .error error => return .parseError error | .error error => return .parseError error
runTermElabM do runTermElabM do
state.restoreElabM state.restoreElabM
state.execute goalId (Tactic.have_t binderName.toName type) state.execute goalId (Tactic.«have» binderName.toName type)
@[export pantograph_goal_evaluate_m]
protected def GoalState.tryEvaluate (state: GoalState) (goalId: Nat) (binderName: String) (type: String): CoreM TacticResult := do
let type ← match (← Compile.parseTermM type) with
| .ok syn => pure syn
| .error error => return .parseError error
runTermElabM do
state.restoreElabM
state.execute goalId (Tactic.evaluate binderName.toName type)
@[export pantograph_goal_let_m] @[export pantograph_goal_let_m]
def goalLet (state: GoalState) (goalId: Nat) (binderName: String) (type: String): CoreM TacticResult := def goalLet (state: GoalState) (goalId: Nat) (binderName: String) (type: String): CoreM TacticResult :=
runTermElabM <| state.tryLet goalId binderName type runTermElabM <| state.tryLet goalId binderName type

View File

@ -19,7 +19,7 @@ def evaluate (binderName: Name) (expr: Syntax): Elab.Tactic.TacticM Unit := do
pure [mvarUpstream.mvarId!] pure [mvarUpstream.mvarId!]
Elab.Tactic.setGoals nextGoals Elab.Tactic.setGoals nextGoals
def have_t (binderName: Name) (type: Syntax): Elab.Tactic.TacticM Unit := do def «have» (binderName: Name) (type: Syntax): Elab.Tactic.TacticM Unit := do
let goal ← Elab.Tactic.getMainGoal let goal ← Elab.Tactic.getMainGoal
let nextGoals: List MVarId ← goal.withContext do let nextGoals: List MVarId ← goal.withContext do
let type ← Elab.Term.elabType (stx := type) let type ← Elab.Term.elabType (stx := type)