caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* old camlp4 quatations
@ 2007-06-12 10:00 Pietro Abate
  0 siblings, 0 replies; only message in thread
From: Pietro Abate @ 2007-06-12 10:00 UTC (permalink / raw)
  To: ocaml ml

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


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2007-06-12 10:00 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-06-12 10:00 old camlp4 quatations Pietro Abate

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).