popl-paper-ocaml/rewriter/ppx_poplpaper.ml
2024-04-22 20:44:55 -05:00

20 lines
No EOL
645 B
OCaml

(* https://tarides.com/blog/2019-05-09-an-introduction-to-ocaml-ppx-ecosystem/ *)
(* https://ocaml-ppx.github.io/ppxlib/ppxlib/writing-ppxs.html#extenders *)
open Ppxlib
let context = Extension.Context.expression
let extender_name = "monomorphic"
let extracter () = Ast_pattern.(single_expr_payload __)
let expander ~ctxt (_: expression) =
let loc = Expansion_context.Extension.extension_point_loc ctxt in
[%expr 5]
let my_extender = Extension.V3.declare extender_name context (extracter()) expander
let extender_rule = Context_free.Rule.extension my_extender
let _ = Driver.register_transformation ~rules:[extender_rule] "polycheck"