caml-list - the Caml user's mailing list
 help / Atom feed
From: Nicolás Ojeda Bär <nicolas.ojeda.bar@lexifi.com>
To: "Richard W.M. Jones" <rich@annexia.org>
Cc: OCaml Mailing List <caml-list@inria.fr>
Subject: Re: [Caml-list] Ast_iterator example?
Date: Fri, 12 Jul 2019 13:40:47 +0000
Message-ID: <CADK7aFPwp6CEtYhphr3aNOHnCX2fK6hPzV=2pLt4CrZos4oX0A@mail.gmail.com> (raw)
In-Reply-To: <20190712132517.4623wwffikbrsqlf@annexia.org>

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 main.ml

Hope it helps,
Nicolás

------ main.ml ---------
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 <rich@annexia.org> wrote:
>
>
> As previously discussed:
> https://sympa.inria.fr/sympa/arc/caml-list/2019-06/msg00050.html
>
> 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:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

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

  git send-email \
    --in-reply-to='CADK7aFPwp6CEtYhphr3aNOHnCX2fK6hPzV=2pLt4CrZos4oX0A@mail.gmail.com' \
    --to=nicolas.ojeda.bar@lexifi.com \
    --cc=caml-list@inria.fr \
    --cc=rich@annexia.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* 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 https://inbox.ocaml.org/caml-list

AGPL code for this site: git clone https://public-inbox.org/ public-inbox