fix: implement · tacs as a builtin elaborator, part 2

Fixes #2153
This commit is contained in:
Sebastian Ullrich 2023-03-15 16:51:29 +01:00
parent c327a61d33
commit a62d412dce
4 changed files with 2 additions and 9 deletions

View file

@ -372,14 +372,9 @@ macro_rules
`($mods:declModifiers class $id $params* extends $parents,* $[: $ty]?
attribute [instance] $ctor)
section
open Lean.Parser.Tactic
syntax cdotTk := patternIgnore("· " <|> ". ")
/-- `· tac` focuses on the main goal and tries to solve it using `tac`, or else fails. -/
syntax (name := cdot) cdotTk tacticSeqIndentGt : tactic
macro_rules
| `(tactic| $cdot:cdotTk $tacs) => `(tactic| {%$cdot ($tacs) }%$cdot)
end
/--
Similar to `first`, but succeeds only if one the given tactics solves the current goal.

View file

@ -157,7 +157,7 @@ private def mkTacticMVar (type : Expr) (tacticCode : Syntax) : TermElabM Expr :=
@[builtin_term_elab noImplicitLambda] def elabNoImplicitLambda : TermElab := fun stx expectedType? =>
elabTerm stx[1] (mkNoImplicitLambdaAnnotation <$> expectedType?)
@[builtin_term_elab cdot] def elabBadCDot : TermElab := fun _ _ =>
@[builtin_term_elab Lean.Parser.Term.cdot] def elabBadCDot : TermElab := fun _ _ =>
throwError "invalid occurrence of `·` notation, it must be surrounded by parentheses (e.g. `(· + 1)`)"
@[builtin_term_elab str] def elabStrLit : TermElab := fun stx _ => do

View file

@ -134,4 +134,3 @@ example : True ∧ False := by
· --
--^ $/lean/plainGoal
--^ $/lean/plainGoal
-- TODO: ^

View file

@ -169,5 +169,4 @@ null
{"rendered": "```lean\ncase left\n⊢ True\n```", "goals": ["case left\n⊢ True"]}
{"textDocument": {"uri": "file://plainGoal.lean"},
"position": {"line": 133, "character": 4}}
{"rendered": "```lean\ncase right\n⊢ False\n```",
"goals": ["case right\n⊢ False"]}
{"rendered": "```lean\ncase left\n⊢ True\n```", "goals": ["case left\n⊢ True"]}