[wg-camlp4] Negative field report: extension points unsuited for (matches p when e)

Alain Frisch alain at frisch.fr
Mon Jul 22 16:27:56 BST 2013


On 05/01/2013 04:44 PM, Gabriel Scherer wrote:
> the piece of code
> we want to parse (<patt> when <expr>) is not syntactically an
> expression. [%matches <patt> when <expr>] would be rejected by the
> parser.

On 05/04/2013 03:27 PM, Leo White wrote:
 > This would
 > allow the example above to be represented as:
 >
 >    [%line: < seq: Line.present; source: Line.present >]


I've extended the branch to support more kinds of payload to 
attributes/extension nodes.  The payload can now be:

   - a structure (including the case of an empty payload and a payload 
reduced to a single expression);

   - a type expression prefixed with ':';

   - a pattern expression prefixed with '?' and optionally followed by a 
'when' clause.

A sum type is used internally to represent the three cases in the Parsetree.

Gabriel's examples could now be written

    [%matches? <patt>]
    [%matches? <patt> when <expr>]

and Leo's example works as-is:

    [%line: < seq: Line.present; source: Line.present >]



-- Alain


More information about the wg-camlp4 mailing list