我在名为module.ml
的文件中使用了Sexplib语法扩展,我希望看到在Camlp4预处理之后输入编译器的代码。有没有一种简单的方法可以使用ocamlfind来实现这一点,还是我必须直接调用camlp4并手动传递所有原始参数?
答案 0 :(得分:2)
此输出
$ camlp4o `ocamlfind query type_conv`/pa_type_conv.cma `ocamlfind query sexplib`/pa_sexp_conv.cma /home/kakadu/.opam/4.01.0/lib/ocaml/camlp4/Camlp4Printers/Camlp4OCamlPrinter.cmo a.ml | pr -t -o4
type t = (int * string)
let _ = fun (_ : t) -> ()
let __t_of_sexp__ =
let _tp_loc = "a.ml.t"
in
function
| Sexplib.Sexp.List ([ v1; v2 ]) ->
let v1 = int_of_sexp v1 and v2 = string_of_sexp v2 in (v1, v2)
| sexp -> Sexplib.Conv_error.tuple_of_size_n_expected _tp_loc 2 sexp
let _ = __t_of_sexp__
let t_of_sexp sexp =
try __t_of_sexp__ sexp
with
| Sexplib.Conv_error.No_variant_match ((_tp_loc, sexp)) ->
Sexplib.Conv_error.no_matching_variant_found _tp_loc sexp
let _ = t_of_sexp
let sexp_of_t (v1, v2) =
let v1 = sexp_of_int v1
and v2 = sexp_of_string v2
in Sexplib.Sexp.List [ v1; v2 ]
let _ = sexp_of_t
对于此来源
$ cat a.ml
type t = int*string with sexp
答案 1 :(得分:2)
使用ocamlbuild
时:
ocamlbuild module.pp.ml
cat _build/module.pp.ml