caml-list - the Caml user's mailing list
 help / Atom feed
From: Nicolás Ojeda Bär <>
To: "Richard W.M. Jones" <>
Cc: OCaml Mailing List <>
Subject: Re: [Caml-list] Ast_iterator example?
Date: Fri, 12 Jul 2019 13:40:47 +0000
Message-ID: <> (raw)
In-Reply-To: <>

Hi Rich,

The code below will parse an .ml file passed on the command line and
run the iterator on the resulting structure. It can be compiled with

    ocamlc -I +compiler-libs ocamlcommon.cma

Hope it helps,

------ ---------
let visit_expr (iterator : Ast_iterator.iterator) expr =

let ast_iterator =
  { Ast_iterator.default_iterator with expr = visit_expr }

let go fn =
  let lexbuf = Lexing.from_channel (open_in fn) in
  let structure = Parse.implementation lexbuf in
  ast_iterator.Ast_iterator.structure ast_iterator structure

let () =
  Arg.parse [] go ""

On Fri, Jul 12, 2019 at 3:25 PM Richard W.M. Jones <> wrote:
> As previously discussed:
> I'm now trying to port ocaml-gettext to use ppx.  However I can't get
> even a trivial Ast_iterator example to compile.  Does anyone have a
> simple compilable example using Ast_iterator?
> Rich.

      reply index

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-12 13:25 Richard W.M. Jones
2019-07-12 13:40 ` Nicolás Ojeda Bär [this message]

Reply instructions:

You may reply publically to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='' \ \ \ \

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

caml-list - the Caml user's mailing list

Archives are clonable: git clone --mirror

AGPL code for this site: git clone public-inbox