From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: * X-Spam-Status: No, score=1.3 required=5.0 tests=AWL,SPF_SOFTFAIL autolearn=disabled version=3.1.3 Received: from discorde.inria.fr (discorde.inria.fr [192.93.2.38]) by yquem.inria.fr (Postfix) with ESMTP id 06446BC0A for ; Thu, 5 Apr 2007 13:00:34 +0200 (CEST) Received: from animal.inescn.pt (ns.inescn.pt [192.35.246.1]) by discorde.inria.fr (8.13.6/8.13.6) with ESMTP id l35B0VIh021009 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Thu, 5 Apr 2007 13:00:33 +0200 Received: from localhost (localhost [127.0.0.1]) by animal.inescn.pt (8.13.8/8.13.6/9) with ESMTP id l35B0UlK027582 for ; Thu, 5 Apr 2007 12:00:30 +0100 (WEST) X-Virus-Scanned: amavisd-new at inescporto.pt Received: from animal.inescn.pt ([127.0.0.1]) by localhost (animal.inescn.pt [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 7mhsPOzo+yPQ for ; Thu, 5 Apr 2007 11:59:59 +0100 (WEST) Received: from [194.117.30.94] (morfina.inescn.pt [194.117.30.94]) by animal.inescn.pt (8.13.8/8.13.8/11) with ESMTP id l35AxBQj027341 for ; Thu, 5 Apr 2007 11:59:11 +0100 (WEST) Message-ID: <4614D67F.1010702@inescporto.pt> Date: Thu, 05 Apr 2007 11:59:11 +0100 From: Hugo Ferreira User-Agent: Thunderbird 1.5.0.10 (X11/20070305) MIME-Version: 1.0 To: caml-list@yquem.inria.fr Subject: camlp4: let binding Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Miltered: at discorde with ID 4614D6CF.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; camlp:01 lident:01 expr:01 pcaml:01 pcaml:01 expr:01 mlast:01 mlast:01 heap:01 heap:01 rec:01 compile:01 patt:01 expression:02 expression:02 Hello, I would like to use a reserved word and substitute that by a function call. For example, the following: let _ = HEAP in let h1 = HEAP in would become let __heap = new_heap () in let h1 = new_heap () in To do this I attempted (here I am not checking the identifier name): binding: [ [ v = LIDENT ; "=" ; "HEAP" -> <:expr<$lid:v$ = new_heap ()>> ] ] ; My problem however is how to activate the rule above? I figured I need something like: Pcaml.str_item : LEVEL "top" [ [ "let"; OPT "rec"; l = LIST1 binding SEP "and" ; "in" -> > ] ]; But this doesn't even compile. I then concentrated on using Pcaml's let_binding function and see If I could simply reconstruct the structured expression but failed. I also tried: Pcaml.expr: LEVEL "expr1" [ [ "let"; l = LIST1 Pcaml.let_binding SEP "and" ; "in" -> <:expr<$l$>> Here I get the error: This expression has type (MLast.patt * MLast.expr) list but is here used with type MLast.expr Now I realize that my problem is (re)constructing the expression of a let binding. I have been at this since yesterday and cannot find a solution. Does anyone have an example of how to do this? TIA, Hugo Ferreira.