You write expressions like that in the following way: expression : ^(OR expression expression) | term ;
term : X | Y | Z ; Then do not create the UPSILON as it will just mislead you. if you feel you need it then add it to term, which although allowing ^(OR EPSILION EPSILON) won't happen because you won't produce that tree. However, don't generally make a token for something that isn't there. Jim > -----Original Message----- > From: [email protected] [mailto:antlr-interest- > [email protected]] On Behalf Of Bart Kiers > Sent: Saturday, March 05, 2011 9:09 AM > To: [email protected] > Cc: [email protected] interest > Subject: Re: [antlr-interest] Tree grammar for expression subrules? > > On Fri, Mar 4, 2011 at 11:23 PM, [email protected] <[email protected]> wrote: > > > > > On 04/03/2011 19:13, Bart Kiers wrote: > > > > I'd expect that to become the tree-grammar rule: > >>> > >>> expression > >>> : term > >>> | ^(OR expression term) > >>> | ^(OR expression EPSILON) > >>> ; > >>> > >> > > Hello Bart > > > > Once again, extremely useful input. Thanks. My question though still > > stands. Cannot discern any pattern in writing the tree rules as, for > > example, this seems to violate cardinality ... or does it? > > > > > > > Hi, I'm starting to hesitate. Could you send your combined- or parser- > grammar that produces the AST? I'll have a look at it to see if I can > create a tree grammar (with a bit of comments). > > Regards, > > Bart. > > List: http://www.antlr.org/mailman/listinfo/antlr-interest > Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your- > email-address List: http://www.antlr.org/mailman/listinfo/antlr-interest Unsubscribe: http://www.antlr.org/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.
