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 891E6BC69 for ; Tue, 3 Jul 2007 10:16:45 +0200 (CEST) Received: from nz-out-0506.google.com (nz-out-0506.google.com [64.233.162.224]) by discorde.inria.fr (8.13.6/8.13.6) with ESMTP id l638Gith003282 for ; Tue, 3 Jul 2007 10:16:45 +0200 Received: by nz-out-0506.google.com with SMTP id z3so1065397nzf for ; Tue, 03 Jul 2007 01:16:44 -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=qjlpzOdO7zSUe9Jk1liu6z+E8BqF/pjq+Bd+h2VcGmVthLahWL0k77J3b14UL8en6O0C+MqEWcrrPYO3yenLUD3dL/hNygwkGkHBJKI0Db6JhbhBu+9W8IMbuUsFjpbN3o7V5u+mk/L++DFUz5d6oTSXflKmcM6h8n7mg7yqCYQ= 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=N/okxvwnm/+xo3IqRkEfAEUTr9oqOj6Fci9pAai0w9b/S19xuwtHNA/wb2HENnzYmrmSP+m7K6cPvlUiwAOY8Y3c0gIHhw9NzK2UcAqsjINFLBzcgS3FD8cfvNf0GktTCFNC5k3MUWTSW75vBGCeBBwcTtyMWLYyJMk483WRn9s= Received: by 10.115.108.1 with SMTP id k1mr5958888wam.1183450603860; Tue, 03 Jul 2007 01:16:43 -0700 (PDT) Received: by 10.114.181.8 with HTTP; Tue, 3 Jul 2007 01:16:43 -0700 (PDT) Message-ID: Date: Tue, 3 Jul 2007 10:16:43 +0200 From: "Nicolas Pouillard" To: "Benedikt Grundmann" Subject: Re: [Caml-list] problem with camlp4 Cc: Caml-list In-Reply-To: <9b415f950707021504q6bad7f65o3adde4cdafea97d5@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <9b415f950707021504q6bad7f65o3adde4cdafea97d5@mail.gmail.com> X-j-chkmail-Score: MSGID : 468A05EC.000 on discorde : j-chkmail score : X : 0/20 1 0.000 -> 1 X-Miltered: at discorde with ID 468A05EC.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; camlp:01 grundmann:01 syntax:01 camlp:01 expr:01 ocamlc:01 -pp:01 -thread:01 lib:01 ocaml:01 expr:01 node:01 cheers:01 wrote:01 integer:01 On 7/3/07, Benedikt Grundmann wrote: > Hi everybody, > > I'm having a problem with a syntax extension I'm trying to write, the > smallest sample that I could come up with, that still shows the > problem is the following: > > (*pp camlp4orf *) > > open Camlp4.PreCast > > let test _loc = > let num = 0 in > let acc = <:match_case<>> in > (* > <:match_case< true -> $expr:num$ | $acc$ >> > *) > <:match_case< true -> 0 | $acc$ >> > > If I comment out the last line and instead enable the line above I get > this error: > > ocamlc -c -pp "camlp4orf " -thread -g -I > /home/bene/godi/lib/ocaml/std-lib/camlp4 sample.ml > File "sample.ml", line 8, characters 23-25: > While expanding quotation "match_case" in a position of "expr": > Parse error: "->" expected after [opt_when_expr] (in [match_case0]) First, "expr" in $expr:...$ is not a valid antiquotation name, (perhaps it should be) but here you can use $exp:...$ or even just $...$ since it's not ambiguous that after the "->" one waits an expression. Second, you try to put an integer right here. You need to make a expression node for it (as told by other answers): - A constant can be put directly: <:expr< 0 >> - A string expression representing an integer can be put like that: <:expr< $int:"0"$ >> - An integer expression can be used with this sugar: <:expr< $`int:0$ >> The last but not the least, in revised <:match_case< true -> 0 >> is nothing more than <:match_case< _ -> 0 >>. Since the true constant is spelled True with a capital T like any other data constructor. Cheers, -- Nicolas Pouillard