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=2.8 required=5.0 tests=AWL,DNS_FROM_RFC_POST, 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 mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by yquem.inria.fr (Postfix) with ESMTP id 644C2BC37 for ; Wed, 16 Sep 2009 09:48:50 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AqQBANI0sErRVdvfkGdsb2JhbACRf4kDPwEBAQEJCQwHEwOwXIEukCoBAwIEhBMFgVY X-IronPort-AV: E=Sophos;i="4.44,396,1249250400"; d="scan'208";a="46671320" Received: from mail-ew0-f223.google.com ([209.85.219.223]) by mail4-smtp-sop.national.inria.fr with ESMTP; 16 Sep 2009 09:48:49 +0200 Received: by ewy23 with SMTP id 23so4441962ewy.26 for ; Wed, 16 Sep 2009 00:48:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=vN6LZ7a9HrLIQqocnyJ/OylFzPa+GmwXadv6ro9fMAQ=; b=H0HDUQn6BCkRqOEQP7ba8S6fRM84bl41Lgbb4R1Ouu4GvFsybn4bM3iX/sOM7XfmyB g7YA71HHWop9kfoVudKWq/Y7r9sq+7CicoKhcb/oAvzXyzbtetwEvF4nOJVWRpTIr3U7 03ULmMajrOJIOgr9YzjXk2eehfxm7Nmk4upIM= 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=P+1EU9Xb2PtH8CJ0dTz+uk5o/opt7qPMi6svFX7okfonPbWcd1TT9P9jRBtBGkFgFG hw6hBEkzw0EPnGxB/IdfyKzSSK6Vye5aqvTAxnuKF7vy00fp1seTMsI9AFD4H+b+TgXl XiPwvnwVdukskIOXSzEN5VtzZUUqJfIKQ9XWk= MIME-Version: 1.0 Received: by 10.211.143.10 with SMTP id v10mr9640084ebn.57.1253087329493; Wed, 16 Sep 2009 00:48:49 -0700 (PDT) In-Reply-To: References: <4b39c80a0909110659oc950714n809ad4f43cd56a62@mail.gmail.com> <4b39c80a0909150526x23ae0eb7o649e60722600a0fd@mail.gmail.com> <00A0564F-D9E3-4FFE-B8A6-E8F4FA5A11FC@recoil.org> Date: Wed, 16 Sep 2009 09:48:49 +0200 Message-ID: <4b39c80a0909160048t1721d410s1b0e6221dbab84c1@mail.gmail.com> Subject: Re: [Caml-list] Re: Generating comments from camlp4 From: Alexey Rodriguez To: Jake Donham Cc: Anil Madhavapeddy , OCaml List Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Spam: no; 0.00; camlp:01 camlp:01 ocamldoc:01 cheers:01 anil:01 anil:01 ocamldoc:01 ocaml:01 ocaml:01 2009:98 2009:98 wrote:01 wrote:01 caml-list:01 functions:01 Thanks for the tip Jake. I arrived to a similar conclusion by doing experiments on source files with comments but I did not pinpoint the exact location in camlp4's sources. As you say, a solution that injects comments would probably look very hacky. I decided to go for Tiphaine's suggestion. After 45 minutes of hacking on the generator, I had decent looking ocamldoc. Thanks Tiphaine! Cheers, Alexey On Wed, Sep 16, 2009 at 3:03 AM, Jake Donham wrote: > On Tue, Sep 15, 2009 at 5:42 AM, Anil Madhavapeddy wrot= e: >> I dont believe you can add comments with camlp4; I'm using type-conv to = hack >> on an ORM layer, and it would be lovely to have the generated functions = also >> have comments to not dirty up the OCamldoc. =A0And also, to maintain san= ity >> when reading through pages of generated OCaml... > > Comments are not passed through the AST, but somehow they make it from > the input file to the output file. It looks like in > Camlp4/Printers/OCaml.ml there is a hook into the tokenizer to keep > track of comments as they are tokenized (search for CommentFilter). > Maybe there is some way to inject comments (at particular locations)? > Possibly by calling Gram.lex_string and/or Gram.filter? A hack, no > doubt. > > Jake >