caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: "Matej Košík" <5764c029b688c1c0d24a2e97cd764f@gmail.com>
To: Gabriel Scherer <gabriel.scherer@gmail.com>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] how (within camlp4 printer) can I traverse AST ?
Date: Wed, 01 Feb 2012 12:01:10 +0000	[thread overview]
Message-ID: <4F292986.30008@gmail.com> (raw)
In-Reply-To: <CAPFanBEQrjnvB5Lvn=F26FH=n08Ch9rxGhv0GVeL97xtx5057w@mail.gmail.com>

On 01/31/2012 10:58 PM, Gabriel Scherer wrote:
> Sig.Ast is the most general structure available, that you use if you
> want to manipulate any kind of grammar for Camlp4. If you know the AST
> you're manipulating corresponds to an OCaml program, you should use
> the more specific Sig.Camlp4Ast signature (as advertized in the
> documentation page for Sig.Ast, btw.). Registering a printer for
> Sig.Camlp4Ast is done with Register.OcamlPrinter, and if you want to
> see a full-blown example of printer, you just have too look at
> camlp4/Camlp4/Printers/OCaml.ml in the ocaml source.

Thank you.

Concerning camlp4/Camlp4/Printers*.ml I am struggling with two problems:

1. these examples are not compiled with ordinary ocamlc/camlp4 tools but
with special ocamlc/camlp4* version built at the "boot time" which are
not interchangeable with regular ocamlc/camlp4* programs. If I try to
use regular ocamlc/camlp4* tools in an attempt to compile those
printers, I will get syntax errors in those printers.

2. the code that registers the printers is not in printers themselves
but it is located in another file, in another context and it is not
obvious how to achieve this action in the context of the code of
individual printers (in an analogous way how sample printer
  http://brion.inria.fr/gallium/index.php/Setup_a_new_printer
directly registers itself.

How would the printer described here:
  http://brion.inria.fr/gallium/index.php/Setup_a_new_printer
look like if I wanted to use concrete instead of abstract syntax---like in:
- DumpOCamlAst
- OCaml.ml
- OCamlr.ml
?

(So that presumably I can compile the printer as shown in the HOWTO.)

  reply	other threads:[~2012-02-01 12:01 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-31 21:26 Matej Košík
2012-01-31 22:58 ` Gabriel Scherer
2012-02-01 12:01   ` Matej Košík [this message]
2012-02-02 16:38     ` Gabriel Scherer
2012-02-13  9:34     ` Hendrik Tews

Reply instructions:

You may reply publicly 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=4F292986.30008@gmail.com \
    --to=5764c029b688c1c0d24a2e97cd764f@gmail.com \
    --cc=caml-list@inria.fr \
    --cc=gabriel.scherer@gmail.com \
    /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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).