On Aug 6, 2010, at 9:07, "Kevin J. Cummings" <cummi...@kjchome.homeip.net> wrote:
> On 08/06/2010 07:33 AM, John B. Brodie wrote: >> Greetings! >> >> On Fri, 2010-08-06 at 02:16 -0400, Ken Klose wrote: >>> Hello, >>> >>> I'm writing my first grammar and have started with something painfully >>> simple but yet cannot figure out why I am receiving errors. At this point >>> I expect my grammar to recognize a whitespace delimited list of integers. >>> Any help is appreciated. > >>> detail: ( integer ); >> >> this rule recognizes just one integer! not a list.... >> >> detail : INTEGER + ; > > Shouldn't it also end with an EOF? > > detail : INTEGER+ EOF ; Unless there is a rule that has detail EOF > >>> integer: ( DIGIT )+; >> >> should probably be a lexer rule >> >> INTEGER : ( DIGIT )+ ; > > INTEGER : DIGIT+ ; > > No need to the ()'s. > Also, then he doesn't need to remove the "fragment" from the DIGIT rule. No. That would DIGIT and INTEGER ambiguous. > >>> fragment DIGIT: '0'..'9'; >>> fragment LETTER : ('a'..'z' | 'A'..'Z'); >>> >>> WS: (' ' | '\t' | '\n' | '\r' | '\f') {$channel = HIDDEN;}; >> >> this rule recognizes (and then ignores) just a single white-space >> character. would be more efficient as >> >> WS : ( ' ' | '\t' | '\n' | '\r' | '\f' )+ {$channel=HIDDEN;} ; > > Maybe, but doesn't it ignore *every* single WS character? > No need to use the + in that case (unless the performance benefit is > significant). It is hiding, not skipping so you would get a hidden token for every whitespace character. Performance says use skip() and + not HIDDEN > > -- > Kevin J. Cummings > kjch...@rcn.com > cummi...@kjchome.homeip.net > cummi...@kjc386.framingham.ma.us > Registered Linux User #1232 (http://counter.li.org) > > 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 il-antlr-inter...@googlegroups.com. To unsubscribe from this group, send email to il-antlr-interest+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/il-antlr-interest?hl=en.