1

The command written in README.md doesn't work (The usage of ocamlfind is shown.) I understand the ppx_metaquot execution file is a kind of rewrite file, so I can translate my code using quasi quotation in this way:

ocamlfind ppx_tools/rewriter ~/.opam/system/lib/ppx_tools/ppx_metaquot  sample.ml

but this may not be an assumed way, so please tell me the correct usage.

henoc
  • 183
  • 1
  • 9

1 Answers1

2

When wd want to use some PPX, normally wd use -package option of ocamlfind:

ocamlfind ocamlc -c -package ppx_tools.metaquot sample.ml

This compiles sample.ml using the preprocessor ppx_tools.metaquot.

If you want to see the output of PPX in human readable form, AFAIK things get a bit more complicated.:

ocamlfind ppx_tools/rewriter -ppx ~/.opam/system/lib/ppx_tools/ppx_metaquot sample.ml

or the following is better:

ocamlfind ppx_tools/rewriter -ppx `ocamlfind query ppx_tools`/ppx_metaquot sample.ml

There might be a simpler way than this but I do not know.

camlspotter
  • 8,990
  • 23
  • 27
  • Thank you, but in my environment, some error occurs using ocamlc: sh: ppx_tools.metaquot: command not found File "mpr.ml", line 1: Error: Error while running external preprocessor Command line: ppx_tools.metaquot '/var/folders/gk/5tlptk8j44751wj4bw_2lzm00000gn/T/camlppxb52f14' '/var/folders/gk/5tlptk8j44751wj4bw_2lzm00000gn/T/camlppx459e01' – henoc Apr 23 '16 at 07:32
  • Ah, sorrry, I made a typo. `ocamlfind ocamlc -c -package ppx_tools.metaquot sample.ml` is the correct one. I fix the answer part too. – camlspotter Apr 23 '16 at 07:40
  • oh, I see, ppx can also be used as a package, thank you. – henoc Apr 24 '16 at 04:46