Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
old camlp4 quatations
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Pietro Abate <Pietro.Abate@a...>
Subject: old camlp4 quatations
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

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

++ Blog:
++ "All great truths begin as blasphemies." -George Bernard Shaw
++ Please avoid sending me Word or PowerPoint attachments.