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 mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by yquem.inria.fr (Postfix) with ESMTP id 2C5D4BBAF for ; Tue, 28 Sep 2010 18:07:49 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Aq0BAIOvoUxKfVO2kGdsb2JhbACiFAgVAQEBAQkJDAcRAx+wBItYhw+JAwEBAwWFPwSEUIVqhWGDJQ X-IronPort-AV: E=Sophos;i="4.57,248,1283724000"; d="scan'208";a="65576497" Received: from mail-pv0-f182.google.com ([74.125.83.182]) by mail2-smtp-roc.national.inria.fr with ESMTP; 28 Sep 2010 18:07:48 +0200 Received: by pvc21 with SMTP id 21so2122239pvc.27 for ; Tue, 28 Sep 2010 09:07:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:mime-version:sender:received :in-reply-to:references:from:date:x-google-sender-auth:message-id :subject:to:cc:content-type:content-transfer-encoding; bh=i9MyOGxG6TSsSbq5roE1WtpRW14jVb2ZRkFvf4YjKa8=; b=PNUboR0R+vJE6olF2xiHlLoLuU6fDZ90Yqp4gMSyqC5sSpjyG7r544pR2lIPxRUBtU If2DjVe9c6Liz15B6LQE61OKhkeybwefqoAv9JE//JVeB2ou0omD2DC88k3rAzibqA10 IhIl9xTTC7RM+PZS6cUqHR4PzaYzU2+yWkxQM= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:from:date :x-google-sender-auth:message-id:subject:to:cc:content-type :content-transfer-encoding; b=QiIqVUQpnWSQd/4IbJi5HaicYVCRVdbqmaIjMps/CCSfESkzyskUV7CtGCULCqw7kF jtCnTPH+KllJuyueI0mHkafkBNqjyZsyt7LP9Q67OGO+YNM59Dvi2R7vQau41bVcF2Fp pZQdgtPkNiPups+2RH/TIVi0w1/r07KJMUZKc= Received: by 10.142.245.21 with SMTP id s21mr95609wfh.329.1285690067592; Tue, 28 Sep 2010 09:07:47 -0700 (PDT) MIME-Version: 1.0 Sender: jake.donham@gmail.com Received: by 10.229.8.11 with HTTP; Tue, 28 Sep 2010 09:07:25 -0700 (PDT) In-Reply-To: References: From: Jake Donham Date: Tue, 28 Sep 2010 09:07:25 -0700 X-Google-Sender-Auth: 67ZVvE3M-1gJFHQqMbSsrOAQrxs Message-ID: Subject: Re: [Caml-list] Chain Camlp4 syntax extensions? To: Dmitry Bely 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 wrote:01 dmitry:01 dmitry:01 caml-list:01 functions:01 On Tue, Sep 28, 2010 at 6:13 AM, Dmitry Bely wrote: > 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: http://www.ocaml.info/home/ocaml_sources.html#toc9 It's trivial to convert an extension to use type-conv. > 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. Jake