feat: remove description argument from register_simp_attr
This commit is contained in:
parent
5b969b75bd
commit
fb259f95db
4 changed files with 15 additions and 8 deletions
|
|
@ -44,7 +44,7 @@ termination_by
|
|||
consumeSpaces n it r => (it, 1)
|
||||
saveLine it r => (it, 0)
|
||||
|
||||
private def removeLeadingSpaces (s : String) : String :=
|
||||
def removeLeadingSpaces (s : String) : String :=
|
||||
let n := findLeadingSpacesSize s
|
||||
if n == 0 then s else removeNumLeadingSpaces n s
|
||||
|
||||
|
|
@ -92,4 +92,9 @@ def getDocStringText [Monad m] [MonadError m] [MonadRef m] (stx : TSyntax `Lean.
|
|||
| Syntax.atom _ val => return val.extract 0 (val.endPos - ⟨2⟩)
|
||||
| _ => throwErrorAt stx "unexpected doc string{indentD stx.raw[1]}"
|
||||
|
||||
def TSyntax.getDocString (stx : TSyntax `Lean.Parser.Command.docComment) : String :=
|
||||
match stx.raw[1] with
|
||||
| Syntax.atom _ val => val.extract 0 (val.endPos - ⟨2⟩)
|
||||
| _ => panic! s!"unexpected doc string\n{stx.raw[1]}"
|
||||
|
||||
end Lean
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ import Lean.Meta.DiscrTree
|
|||
import Lean.Meta.AppBuilder
|
||||
import Lean.Meta.Eqns
|
||||
import Lean.Meta.Tactic.AuxLemma
|
||||
import Lean.DocString
|
||||
namespace Lean.Meta
|
||||
|
||||
/--
|
||||
|
|
@ -415,12 +416,13 @@ def SimpTheoremsArray.isErased (thmsArray : SimpTheoremsArray) (thmId : Name) :
|
|||
def SimpTheoremsArray.isDeclToUnfold (thmsArray : SimpTheoremsArray) (declName : Name) : Bool :=
|
||||
thmsArray.any fun thms => thms.isDeclToUnfold declName
|
||||
|
||||
macro (name := _root_.Lean.Parser.Command.registerSimpAttr) doc?:(docComment)?
|
||||
"register_simp_attr" id:ident descr:str : command => do
|
||||
macro (name := _root_.Lean.Parser.Command.registerSimpAttr) doc:docComment
|
||||
"register_simp_attr" id:ident : command => do
|
||||
let str := id.getId.toString
|
||||
let idParser := mkIdentFrom id (`Parser.Attr ++ id.getId)
|
||||
`($[$doc?]? initialize ext : SimpExtension ← registerSimpAttr $(quote id.getId) $descr $(quote id.getId)
|
||||
$[$doc?]? syntax (name := $idParser:ident) $(quote str):str (Parser.Tactic.simpPre <|> Parser.Tactic.simpPost)? (prio)? : attr)
|
||||
let descr := quote (removeLeadingSpaces doc.getDocString)
|
||||
`($doc:docComment initialize ext : SimpExtension ← registerSimpAttr $(quote id.getId) $descr $(quote id.getId)
|
||||
$doc:docComment syntax (name := $idParser:ident) $(quote str):str (Parser.Tactic.simpPre <|> Parser.Tactic.simpPost)? (prio)? : attr)
|
||||
|
||||
end Meta
|
||||
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ register_builtin_option testb : Nat := {
|
|||
}
|
||||
|
||||
/-- My new simp attribute -/
|
||||
register_simp_attr mysimp "my simp attr"
|
||||
register_simp_attr mysimp
|
||||
|
||||
/-- config elab -/
|
||||
declare_config_elab elabSimpConfig' Lean.Meta.Simp.Config
|
||||
|
|
|
|||
|
|
@ -4,8 +4,8 @@ open Lean
|
|||
|
||||
initialize blaAttr : TagAttribute ← registerTagAttribute `bla "simple user defined attribute"
|
||||
|
||||
/-- My new simp attribute -/
|
||||
register_simp_attr my_simp "my own simp attribute"
|
||||
/-- My own new simp attribute. -/
|
||||
register_simp_attr my_simp
|
||||
|
||||
syntax (name := foo) "foo" num "important"? : attr
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue