[wg-camlp4] My uses of syntax extension

Leo White lpw25 at cam.ac.uk
Mon Jan 28 15:43:18 GMT 2013


>  Btw: do you have a clear idea how to implement ast lifting in ppx(
>the meta filter in p4) which is an essential part in
>quasi-quotation?(the stream parsers have non-trivial optimizations
>which depends on it )

I don't think that it is necessery for how I think we should implement 
anti-quotations.

If you consider some quotation with an anti-quotation like:

let body x = 
<:html < <body attr=$x$> Hello, World <\body> >>

When the quotation's parser sees the first "$" it knows it has found an 
anti-quotation. What it then needs to do is ask an OCaml parser to try to 
parse an expression with all the text up until the next unnested "$". With 
a bit of care we can provide this ability with the main compiler's parser 
(which can be linked to through comper-libs).

The quotation parser will then have an parsetree node of type expression. 
Since it is building a parsetree expression to replace the quotation, the 
parsetree node of the antiquotation can be included within this expression 
directly.



More information about the wg-camlp4 mailing list