Version française
Home     About     Download     Resources     Contact us    
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: -- (:)
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 
tree.

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 
mean?


Martin

--
Martin Jambon, PhD
http://martin.jambon.free.fr