On Mon, Jul 26, 2010 at 6:30 PM, Jake Donham <j...@donham.org> wrote:
> On Mon, Jul 26, 2010 at 8:41 AM, Raphael Proust <raphla...@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

_______________________________________________
Caml-list mailing list. Subscription management:
http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
Archives: http://caml.inria.fr
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs

Reply via email to