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
camlp4 question
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2005-09-08 (17:37)
From: Martin Jambon <martin_jambon@e...>
Subject: Re: [Caml-list] Re: camlp4 question
On Thu, 8 Sep 2005, Christophe Raffalli wrote:

> Yet another question ....
> I was assuming you oculd ask the type of an expression in camlp4 to do an 
> induction over it (the type) ....

You can't, Camlp4 is only about parsing and transforming the syntax 

I imagine you could use a (complicated) 3-step approach:
1) preprocess the file with camlp4 and ignore the syntax extensions
2) compile the result with -dtypes
3) fetch the type information from the .annot file and reparse the 
original file with camlp4. This time you can get the type of 
each identifier and expand your special syntax constructs

> I do not see that in the manual !
> (you can only construct trees with camlp4, but you cannot match them ?)

You can use quotations in patterns to read the syntax tree. Is it what you 


Martin Jambon, PhD