From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Delivered-To: caml-list@yquem.inria.fr Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id 9630CBC48 for ; Tue, 19 Apr 2005 17:13:33 +0200 (CEST) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id j3JFDWUn015495 for ; Tue, 19 Apr 2005 17:13:32 +0200 Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id RAA18381 for ; Tue, 19 Apr 2005 17:13:32 +0200 (MET DST) Received: from wproxy.gmail.com (wproxy.gmail.com [64.233.184.207]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id j3JFDVBU030128 for ; Tue, 19 Apr 2005 17:13:32 +0200 Received: by wproxy.gmail.com with SMTP id 69so1525184wra for ; Tue, 19 Apr 2005 08:13:31 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=Ojd32vTIp89md37Rvkxf8Nl7zF2ka4ITG7tNVNSreiSKNDc81aKUgu3yTNTqEfpuyHjF0g9fuLJl6yiKYwMpT8ImBMuEgMb/qftZ79+xpGEmq5ywImDeYfjkbk71YsvNcdBPDiiLgYQlA25Zkiiqi/SWxpivjAGYJMtmDPBbBng= Received: by 10.54.16.30 with SMTP id 30mr362185wrp; Tue, 19 Apr 2005 08:13:30 -0700 (PDT) Received: by 10.54.22.11 with HTTP; Tue, 19 Apr 2005 08:13:30 -0700 (PDT) Message-ID: Date: Tue, 19 Apr 2005 11:13:30 -0400 From: Markus Mottl Reply-To: Markus Mottl To: Martin Jambon Subject: Re: [Caml-list] Camlp4: extending syntax of record definitions Cc: OCaml In-Reply-To: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline References: X-Miltered: at concorde with ID 4265201C.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at nez-perce with ID 4265201B.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; markus:01 mottl:01 markus:01 mottl:01 caml-list:01 syntax:01 grammar:01 syntax:01 uncommented:01 ocaml:01 ocaml:01 wrote:01 rewrite:01 simpler:01 functions:01 X-Spam-Checker-Version: SpamAssassin 3.0.2 (2004-11-16) on yquem.inria.fr X-Spam-Status: No, score=0.5 required=5.0 tests=INFO_TLD,RCVD_BY_IP autolearn=disabled version=3.0.2 X-Spam-Level: On 4/18/05, Martin Jambon wrote: > My experience in that field tells me that the more you try to extend > existing syntaxic constructs, the more difficult it is. >=20 > You have to look at pa_o.ml from the Camlp4 distribution first, and see i= f > the rule corresponding to record definitions is public (belongs to > a "GLOBAL" entry) or not. I had already copied half of the grammar to add my extension, but then I thought that this is insane. I couldn't believe that there is no simpler way of doing that, but obviously there really isn't. > If the entry that contains this rule is public, then you can delete the > rule and rewrite it, and everything is fine. > Otherwise, you have to improvise. Which is the case here: the type_kind > entry is not visible from outside. Right. I had to essentially copy everything from "type_declaration" downwards, which is quite a lot. > One reasonable solution, in general, if you have a limited time or budget= , > is to extend str_item (items of a module implementation) with > a whole new syntax. Something like: I don't think that this is necessary, because it's only the type declaration I want to change, not the syntax for record expressions. The user must call the validation functions manually on his values. > You can look at this example (uncommented), which is very similar: > http://martin.jambon.free.fr/extend-ocaml-syntax.html#types Thanks, that's a very nice tutorial on Camlp4. Maybe it could be added to the documentation index for OCaml at INRIA? Best regards, Markus --=20 Markus Mottl http://www.ocaml.info markus.mottl@gmail.com