[wg-camlp4] parse_with_ppx [was: My no-use of camlp4 syntax extensions for Otags]
Alain Frisch
alain.frisch at lexifi.com
Tue Sep 10 15:22:42 BST 2013
On 08/22/2013 02:21 PM, Hendrik Tews wrote:
> a long time ago I asked about function parse_with_ppx, that takes
> a file name, applies -pp preprocessors, parses the result,
> applies -ppx preprocessors and returns the syntax tree.
>
> Is such a function available in 4.01 beta? Or, could somebody
> point me to the relevant code in ocamlc/ocamlopt that does that?
The functionality is now in trunk and will be part of 4.02. The
functions to use are in the module Pparse:
val parse_implementation: formatter -> string -> Parsetree.structure
val parse_interface: formatter -> string -> Parsetree.signature
You need to parse the command-line to detect -pp/-ppx flags and also
deal with error reporting, though.
Example:
https://github.com/alainfrisch/ppx_tools/blob/master/dumpast.ml
Alain
More information about the wg-camlp4
mailing list