Version française
Home     About     Download     Resources     Contact us    
Browse thread
Chain Camlp4 syntax extensions?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Jake Donham <jake@d...>
Subject: Re: [Caml-list] Chain Camlp4 syntax extensions?
On Tue, Sep 28, 2010 at 6:13 AM, Dmitry Bely <dmitry.bely@gmail.com> wrote:
> I have two similar syntax extension that generate some functions for
> each type in the module:
>
> EXTEND Gram
>  str_item:
>    [ [ "type"; tdl = LIST1 type_declaration SEP "and" ->
>        ...
> 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