caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Pietro Abate <Pietro.Abate@anu.edu.au>
To: ocaml ml <caml-list@inria.fr>
Subject: old camlp4 quatations
Date: Tue, 12 Jun 2007 20:00:02 +1000	[thread overview]
Message-ID: <20070612100002.GA32094@pulp.rsise.anu.edu.au> (raw)

Hi all,
suppose I want to use camlp4 to parse an ocaml program and output the
same program in an other language.

For the parsing part, I figured out, I've to copy the grammar that in
part of the camlp4 distribution. For the output part I'd like to
re-write part of the quotation system of camlp4 to output this
new language. 

It's not exactly clear to me how I can work this out... This is my
understanding:

If I use the quotation module of camlp4, I can either return a string
(ExStr) for expressions or patterns or a syntax tree (ExAst) that is
defined in the module mLast.

Once I've the AST, I've to pretty print it in the target language. Since
the AST that is accepted by the quotation module is the ocaml ast, and
assuming I can use the same ast for my language, the only thing to be
done is to re-write the pp to output the my language... The printer for
the ocaml ast is pr_o and the q_MLast module contains the manipulation
functions to transform the ast into a printable form...

Is this correct ? Do you know of any similar use of camlp4 that I can
look at ?

thanks :)
p



-- 
++ Blog: http://blog.rsise.anu.edu.au/?q=pietro
++ 
++ "All great truths begin as blasphemies." -George Bernard Shaw
++ Please avoid sending me Word or PowerPoint attachments.
   See http://www.fsf.org/philosophy/no-word-attachments.html


                 reply	other threads:[~2007-06-12 10:00 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20070612100002.GA32094@pulp.rsise.anu.edu.au \
    --to=pietro.abate@anu.edu.au \
    --cc=caml-list@inria.fr \
    /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).