> -----Original Message----- > From: [email protected] [mailto:antlr-interest- > [email protected]] On Behalf Of Ben Corne > Sent: Tuesday, May 17, 2011 6:44 AM > To: [email protected] > Subject: Re: [antlr-interest] Automatic lists > > Found it in the definitive antlr guide: adding a ? behind $docs did the > trick.
Actually you need to correct the cardinality of the list, not an element: $docs* - 0 or more docs $docs+ - 1 ot more docs $docs - 1 doc (no list) $docs? - 0 or 1 docs (no list) So, where you are using += you need to use the list versions of the references. Jim > 2011/5/17 Ben Corne <[email protected]> > > > Hi > > > > I'm trying to create a rule looking like this: > > ================================== > > statement > > : ( docs+=documentation )* > > ( def=definition -> ^(AGSTATEMENT $docs $def) | > tdef=typedefinition > > -> ^(AGSTATEMENT $docs $tdef) > > | imp=imports -> ^(AGSTATEMENT $docs $imp) > > // TODO: (variable EQL) => varassignment > > // TODO: (assignment) => assignment | exp=expression -> > > ^(AGSTATEMENT $exp $docs) > > ; > > ================================== > > > > This rule should add a bunch of documentation constructs to each type > > of statement. Testing with at least one documentation per statement, > > everything works as expected. > > > > Now the problem is that when I test statements without any > > documentation added to a statement, the ANTLRworks debugger seems to > > stop after the first such statement, refusing to go parse the > folowing statements. > > > > I suspect that it is because the $docs variable is never initialized > > since nothing is added. How should I fix this? > > > > Regards > > Ben C. > > > > 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.
