Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Camlp4] Quotation expander with OCaml syntax
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Raphael Proust <raphlalou@g...>
Subject: Re: [Caml-list] [Camlp4] Quotation expander with OCaml syntax
On Mon, Jul 26, 2010 at 6:30 PM, Jake Donham <jake@donham.org> wrote:
> On Mon, Jul 26, 2010 at 8:41 AM, Raphael Proust <raphlalou@gmail.com> wrote:
>> What I basically need is to get an AST with antiquotations and quotations being
>> special nodes. How is this achievable w/o reimplementing a whole grammar?
>
> There is already a special node for antiquotations, but not
> quotations; see below.
>
>> The alternative solution is to use raw strings, to find antiquotation marks, to
>> split the string and to reinject it in the different files. Is there a way to
>> keep precise _loc information this way?
>
> [...]
>
> I'm not sure what syntactic problems Nicolas suggests you would run
> into by reusing the existing parser and quotation mechanism. But it
> might be a bit hairy to implement. One issue is that you can't just
> drop antiquotations anywhere; where they can appear (and with what
> tag) is given by the parser. If you want to go in this direction, the
> place to start would be Camlp4QuotationCommon.ml, which implements
> OCaml AST quotations / antiquotations. You can see there that you can
> parse starting at arbitrary non-terminals, and you can filter the
> OCaml AST without a giant pattern match using the Ast.map object.

I'll read the Camlp4QuotationCommon source code and try to have something like
{:on{ f $y$ }} working. Thanks for the answer and thanks for the Camlp4 blog
post series, it helped me a lot to get the first version of my extension
working!



-- 
_______
Raphael