[wg-camlp4] Matching on concrete syntax (was: Re: Camlp4 uses)
Hongbo Zhang
hongboz at seas.upenn.edu
Sat Mar 30 05:00:37 GMT 2013
> This might be a matter of taste, but I prefer the PPX version, which I can
> read only by knowing about the Parsetree (which is required anyway to write
> any such code), a normal OCaml library. The quotation and anti-quotations
> in the Camlp4 version look very noisy, and it relies on a syntax I'm not
> familiar with (revised syntax) and syntactic extensions
> (quotations/antiquotations), with their own conventions ("<:match_case<",
> $lid:$).
This is an interesting point. Actually I have an idea to make it more named
antiquotation more tractable, that's instead of allowing antiquote
everything, only a lower identifier is allowed to be antiquoted. so
{:exp| .... $x ....|} (*allowed *)
{:exp| ... $(arbitrary expression ) ||} (* Disallowed*)
let a = (arbitrary expression) in
{:exp| ... $a .... |} (* written this way*)
Based on such simplified antiquotation, named antiquotation is no longer
context-sensitive, which means for all syntax categories:
$lid:x -> `Lid (_loc,x)
$uid:x -> `Uid (_loc,x)
....
Such rules should not be hard to remember and quite intuitive. In terms of
implementation, I think this is already available in Fan, Camlp4's
antiquotation uses both Ant constructor and string mangling, it make some
time to implement, but should not be too difficult.
>
>
> -- Alain
>
> ______________________________**_________________
> wg-camlp4 mailing list
> wg-camlp4 at lists.ocaml.org
> http://lists.ocaml.org/**listinfo/wg-camlp4<http://lists.ocaml.org/listinfo/wg-camlp4>
>
--
-- Regards, Hongbo
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ocaml.org/pipermail/wg-camlp4/attachments/20130330/fb6116cf/attachment.html>
More information about the wg-camlp4
mailing list