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.1 required=5.0 tests=AWL,SPF_NEUTRAL autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from discorde.inria.fr (discorde.inria.fr [192.93.2.38]) by yquem.inria.fr (Postfix) with ESMTP id 4D805BC69 for ; Tue, 20 Mar 2007 11:54:13 +0100 (CET) Received: from wx-out-0506.google.com (wx-out-0506.google.com [66.249.82.228]) by discorde.inria.fr (8.13.6/8.13.6) with ESMTP id l2KAsC8U020713 for ; Tue, 20 Mar 2007 11:54:12 +0100 Received: by wx-out-0506.google.com with SMTP id i26so1829056wxd for ; Tue, 20 Mar 2007 03:54:12 -0700 (PDT) DKIM-Signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=qqHMj373Jmm4uHLrVg6XJo5iJSMLQQ1Xlr3dj+WaGGRbOXguueuAThdlHQgoGT+JDJyeghfH++AKTaST9+sdtBm7QnxA3l/1t8N5jYLWf26r1lc8lgSkSDE1gmY1Q3S63nSd1CRGijf0IXjXGnHxq73GrIJ6fTDanHbMMDYIRUA= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=hUYjbzc4xKTJQ974/xrXdMYgQ1HlLpjqB2bU28pzE4p55sM8HuSSltJJGlLYdf2A+UpElmD9R9KM4duvufox93Nrw9xwz6XW2UT/34WygqK5QMQSXAnHjJENtSruuR/sko7wzVt7b9/9OlF8w2bT8fpEP+YljaZjZDvf8OXyzoU= Received: by 10.90.72.10 with SMTP id u10mr264802aga.1174388051812; Tue, 20 Mar 2007 03:54:11 -0700 (PDT) Received: by 10.114.183.4 with HTTP; Tue, 20 Mar 2007 03:54:11 -0700 (PDT) Message-ID: Date: Tue, 20 Mar 2007 11:54:11 +0100 From: "Nicolas Pouillard" To: "Hugo Ferreira" Subject: Re: [Caml-list] camlp4: processing lists Cc: caml-list@yquem.inria.fr In-Reply-To: <45FFB71B.3080002@inescporto.pt> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <45FFB71B.3080002@inescporto.pt> X-j-chkmail-Score: MSGID : 45FFBD54.000 on discorde : j-chkmail score : X : 0/20 1 0.000 -> 1 X-Miltered: at discorde with ID 45FFBD54.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; camlp:01 camlp:01 expr:01 expr:01 iter:01 endline:01 pcaml:01 pcaml:01 ocaml:01 bug:01 iter:01 endline:01 syntax:01 syntax:01 bug:01 On 3/20/07, Hugo Ferreira wrote: > Hello, > > I have sent this post to the new ocaml-developer list but am resending > it here in the hopes that someone can help me. I have come across a > weirdness in camlp4. Maybe someone can explain this puzzle to me. > > I have the following extension: > > let expand_term_list loc l = > let nl = <:expr< [] >> in > let nl = List.fold_right (fun h t -> > <:expr< [$h$::$t$] >> > ) l nl in > <:expr< > do { > List.iter (fun i -> print_endline i) $nl$ > } > >> > > EXTEND > Pcaml.expr: [ > [ > "|" ; "[" ; l = LIST0 Pcaml.expr SEP ";" ; "]" ; "|"-> Pcaml.expr is too greedy here. Since 1; 2 is a valid ocaml expression. You need to choose another level ("expr1" in your case and "top" in 3.10). > "|" ; "[" ; l = LIST0 Pcaml.expr LEVEL "expr1" SEP ";" ; "]" ; "|"-> > expand_term_list loc l ] ]; > END;; > [...] > > let t1 = > do { > print_string "Not implemented for list "; Here you reached a bug (fixed for 3.10) > List.iter (fun i -> print_endline i) > [do { "1"; "f(X,Y)"; "g(X,Y)"; "4" }] > } > in > () > > which ... to say the least is *not* what I expected. I initially I > though I had but one Pcaml.expr and not a list of those. What seems > to be happening is that the revised syntax is used to generate the > code and this is wrong. The in revised 1; 2 is not a valid expression you need to add do { ... } thus by printing it in the revised syntax you see that was not what you want. BTW it was a bug in camlp4 to print [1; 2] where it was [(1; 2)]. Hope this helps, -- Nicolas Pouillard