23 lines
702 B
Text
23 lines
702 B
Text
import Lean
|
||
|
||
open Lean
|
||
|
||
initialize blaAttr : TagAttribute ← registerTagAttribute `bla "simple user defined attribute"
|
||
|
||
/-- My own new simp attribute. -/
|
||
register_simp_attr my_simp
|
||
|
||
syntax (name := foo) "foo" num "important"? : attr
|
||
|
||
initialize fooAttr : ParametricAttribute (Nat × Bool) ←
|
||
registerParametricAttribute {
|
||
name := `foo
|
||
descr := "parametric attribute containing a priority and flag"
|
||
getParam := fun _ stx =>
|
||
match stx with
|
||
| `(attr| foo $prio:num $[important%$imp]?) =>
|
||
return (prio.getNat, imp.isSome)
|
||
| _ => throwError "unexpected foo attribute"
|
||
afterSet := fun declName _ => do
|
||
IO.println s!"set attribute [foo] at {declName}"
|
||
}
|