Browse thread
Generating comments from camlp4
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: | 2009-09-16 (07:48) |
From: | Alexey Rodriguez <mrchebas@g...> |
Subject: | Re: [Caml-list] Re: Generating comments from camlp4 |
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 <jake@donham.org> wrote: > On Tue, Sep 15, 2009 at 5:42 AM, Anil Madhavapeddy <anil@recoil.org> wrote: >> 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. And also, to maintain sanity >> 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 >