[antlr-interest] C# and '?' cardinality operator in AST rewrite rules

Benoit Miller fulg at iname.com
Sat Jan 6 16:28:38 PST 2007


Hello Kay,

Kay Roepke wrote:
> keep in mind that ^(attrList VAR_INT ID) is the tree:
> 
>          attrList
>           /    \
>       VAR_INT   ID
> 
> Making the root node optional is probably not well defined in any case...

Hmm, bitten by my example again :) I oversimplified the repro.

Here is the unedited rule:

classDecl : attrList? 'class' IDENTIFIER '{' property+ '}' ';'
             -> ^(CLASS IDENTIFIER attrList? property+)
           ;

In the AST rewrite rule, there is a dummy token as the root.

Thanks,
Ben.

[PS: I mistakenly sent this to Kay only, can someone fix the list 
Reply-To, or is this desired behavior?]


More information about the antlr-interest mailing list