popl-paper-ocaml/rewriter/ppx_poplpaper.ml

20 lines
645 B
OCaml
Raw Normal View History

2024-04-23 01:44:55 +00:00
(* 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"