On Sep 29, 2008, at 1:44 PM, David Pearce wrote:
> Hi Terence,
>
>> Yes. you must use
>>> list : '(' listBody ')' -> ^(LIST listBody?)
>> not
>>> list : '(' listBody ')' -> ^(LIST listBody)
>> clearly listBody can be optional, right?
>
> Yes, in this case it is definitely optional. But, in the Java
> grammar case it is not:
Notice the ? is in the tree construction not the matching.
>> classDeclaration
>> : 'class' Identifier (typeParameters)?
>> ('extends' type)? ('implements' typeList)?
>> classBody
>> ;
>> ...
>> classBody
>> : '{' classBodyDeclaration* '}'
>> ;
>> ...
>> classBodyDeclaration
>> : ';'
>> | ... [other productions]
>> ;
I don't understand the issue. Don't alter the matching, just add ? to
the ast constr.
Ter
List: http://www.antlr.org:8080/mailman/listinfo/antlr-interest
Unsubscribe:
http://www.antlr.org:8080/mailman/options/antlr-interest/your-email-address
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"il-antlr-interest" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/il-antlr-interest?hl=en
-~----------~----~----~----~------~----~------~--~---