[wg-camlp4] My uses of syntax extension

Alain Frisch alain at frisch.fr
Mon Jan 28 16:51:34 GMT 2013


On 01/28/2013 05:44 PM, Fabrice Le Fessant wrote:
> On 01/28/2013 05:26 PM, Leo White wrote:
>>
>>> In my ocaml-templates approach, the "html" parser would just receive a
>>> string "<body attr=$x$> Hello, World <\body>", and call its parser,
>>> that would have to understand anti-quotations, by returning a node
>>> Pquotation("ocaml", "x") telling the typer that it should call the
>>> ocaml parser on the string "x"...
>>
>> The problem with this method is that it does not support nested
>> anti-quotations, or any other occurrence of the closing delimiter (the
>> second "$") within the expression. You don't know whether "x" is the
>> expression that needs to be parsed without asking the OCaml parser.
>
> Of course. For that, anyway, you need a "standard" of quotations and
> anti-quotations, i.e. all parsers must obey the rule that
> anti-quotations are between $...$ and quotations between <:XXX< ... >>.
> Then, you don't need to know the syntax within the (anti-)quotations,
> you can delegate parsing at the time the parsetree is needed.

We need to be careful about lexical conventions: do we lex strings and 
comments as the standard lexer within quotations, for instance?  Do we 
provide a mechanism to escape the closing delimiters?

-- Alain


More information about the wg-camlp4 mailing list