| 1 | open Names |
| 2 | |
| 3 | let print_hook = |
| 4 | let attr : Declare.Hook.t list Attributes.attribute = |
| 5 | let hook = Declare.Hook.make @@ fun data -> |
| 6 | Feedback.msg_info Pp.(str "generated " ++ GlobRef.print data.dref ++ str "\n") |
| 7 | in |
| 8 | let open Attributes in |
| 9 | let open Attributes.Notations in |
| 10 | map (Option.default []) @@ attribute_of_list [("print", fun ?loc _ _ -> [hook])] |
| 11 | in |
| 12 | Vernacentries.DefAttributes.Observer.register ~name:"print-afterwards" attr |
| 13 | |
| 14 | |
| 15 | let error_hook = |
| 16 | let attr : Declare.Hook.t list Attributes.attribute = |
| 17 | let hook loc = Declare.Hook.make @@ fun data -> |
| 18 | Feedback.msg_info Pp.(str "failing attribute") ; |
| 19 | CErrors.user_err ?loc Pp.(str "attribute error!") |
| 20 | in |
| 21 | let open Attributes in |
| 22 | let open Attributes.Notations in |
| 23 | map (Option.default []) @@ attribute_of_list [("error", fun ?loc _ _ -> [hook loc])] |
| 24 | in |
| 25 | Vernacentries.DefAttributes.Observer.register ~name:"error" attr |
| 26 | |
| 27 | let () = |
| 28 | Mltop.(declare_cache_obj_full @@ interp_only_obj @@ fun () -> |
| 29 | Vernacentries.DefAttributes.Observer.activate print_hook; |
| 30 | Vernacentries.DefAttributes.Observer.activate error_hook) |
| 31 | "rocq-test-suite.attribute" |