From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by yquem.inria.fr (Postfix) with ESMTP id 4F6C4BBAF for ; Tue, 28 Sep 2010 18:55:07 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Aq0BAIe6oUzRVdI2kGdsb2JhbACiFAgVAQEBAQkJDAcRAx+wO4lBgheHHS6IVQEBAwWFPwSES4VvhWE X-IronPort-AV: E=Sophos;i="4.57,248,1283724000"; d="scan'208";a="73917723" Received: from mail-pz0-f54.google.com ([209.85.210.54]) by mail1-smtp-roc.national.inria.fr with ESMTP; 28 Sep 2010 18:55:06 +0200 Received: by pzk7 with SMTP id 7so2084966pzk.27 for ; Tue, 28 Sep 2010 09:55:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:in-reply-to :references:date:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=7gx8EDIzSKNiXt7UcEN/1qmJIYaPtmtEKPgP/+wy6SY=; b=sdVi+Gk30h6V8UxFsBRsn4epf0H6e+oJ7j03ElSGVce80hXmXuAyyyE82ZAz84A/EK 0N1JtJVskhDBH6m+G1C1qIKivrOIGtLk4cBImnLC90Q6waErU+PwNSn04FQiNa56SCCR ZKEb1xgFETfRGZjBZxgrfhRfi/donO/n4sRfs= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; b=lX3tTIqNJEdT1f5s5U+Mb5rdnBkkYe9XKbbvKhFhgaBdZfxQb+anTOIGFGnEK9VDKm zGGpkI/Y2pfBzodn2Buzouj6i0ai2W3jz0P6pfPvj8qzYs0uu5Z5MouHnpYbNiOHbPIc PRq1guRZ9KtsAeyujk6NfFB9FSln8vRCBUwr8= MIME-Version: 1.0 Received: by 10.114.201.18 with SMTP id y18mr279027waf.138.1285692900880; Tue, 28 Sep 2010 09:55:00 -0700 (PDT) Received: by 10.115.79.8 with HTTP; Tue, 28 Sep 2010 09:55:00 -0700 (PDT) In-Reply-To: References: Date: Tue, 28 Sep 2010 20:55:00 +0400 Message-ID: Subject: Re: [Caml-list] Chain Camlp4 syntax extensions? From: Dmitry Bely To: Jake Donham Cc: Caml List Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Spam: no; 0.00; camlp:01 syntax:01 syntax:01 ocaml:01 ocaml:01 trivial:01 camlp:01 doable:01 bool:01 28,:98 28,:98 wrote:01 wrote:01 dmitry:01 dmitry:01 On Tue, Sep 28, 2010 at 8:07 PM, Jake Donham wrote: > On Tue, Sep 28, 2010 at 6:13 AM, Dmitry Bely wrot= e: >> I have two similar syntax extension that generate some functions for >> each type in the module: >> >> EXTEND Gram >> =A0str_item: >> =A0 =A0[ [ "type"; tdl =3D LIST1 type_declaration SEP "and" -> >> =A0 =A0 =A0 =A0... >> END; > > There is not a good solution without modifying the extensions; looking > at the signature of the Grammar module, you can modify a grammar but > not look up or call existing rules / actions. > > This problem of combining extensions for type-derived functions is the > motivation for the type-conv framework: > > =A0http://www.ocaml.info/home/ocaml_sources.html#toc9 > > It's trivial to convert an extension to use type-conv. Thanks. But I have not found any docs for type-conv package. Is there any example demonstrating how to make Camlp4 grammar compatible with type-conv framework? >> And another question. For camlp5 it was possible to inject some code >> into the beginning of the generated file > > It should be doable with a filter and a bool ref---inject the code > into the first str_item then set the flag so you don't add it to the > others. Thanks again. Indeed this is the way to go. - Dmitry Bely