[wg-camlp4] On domain-specific foreign syntaxes

Gerd Stolpmann info at gerd-stolpmann.de
Fri Feb 1 09:34:10 GMT 2013


Am 01.02.2013 08:38:18 schrieb(en) Alain Frisch:
> Something else: I suggest that the "marker" (lid in your examples)  
> for extension node (whether they are combined with quotations or not)  
> could rather be a general expression than just an identifier (maybe  
> with a lighter syntax for the simple identifier case).  (In the  
> Parsetree, we would have "Pexp_extension of expression * expression"  
> instead of "Pexp_extension string * expression".)  This is to support  
> passing arguments to the "expander".  Of course, those arguments  
> could be encoded in the "content", but I believe it makes sense to  
> distinguish those two concepts.  In particular, if you use the  
> combined extension + quotation form, you probably want parsed  
> arguments even with unparsed content:
> 
>  {:(html ~strict ~antiquot:'$') |<div class=$x/>|}

I don't think users would like this style in general - you don't want  
to repeat configuration aspects like ~strict and ~antiquot in every  
quotation. Normally the same configuration applies to a whole  
subexpression or even the whole file.

For the few camlp4 parsers I wrote I used special configuration  
quotations for this purpose, i.e. here

{:html_config ~strict ~antiquot:'$'}

and this would apply "for the rest" whatever this is. But this was rare  
so far, I can remember there was one such configuration for the  
character set of generated XML docs.

Gerd



> 
> 
>> Considering a parser is probably more effort to write than an AST
>> transformer, I don't think you need to worry too much.
> 
> (Requiring more effort is unfortunately often valued as a good thing!)
> 
> 
> Alain
> _______________________________________________
> wg-camlp4 mailing list
> wg-camlp4 at lists.ocaml.org
> http://lists.ocaml.org/listinfo/wg-camlp4
> 


-- 
------------------------------------------------------------
Gerd Stolpmann, Darmstadt, Germany    gerd at gerd-stolpmann.de
Creator of GODI and camlcity.org.
Contact details:        http://www.camlcity.org/contact.html
Company homepage:       http://www.gerd-stolpmann.de
------------------------------------------------------------


More information about the wg-camlp4 mailing list