Thanks.. I think it looks good atleast to me.. But i think i would go with using @init part, but instead of overriding the nextToken, i will override the getErrorMessage() function. I just feel that compairson for every nextToken call might be slightly costly.
But thanks for the solution. Gokul. On Thu, Jul 16, 2009 at 5:05 PM, Michael <[email protected]> wrote: > Am Thursday 16 July 2009 12:14:55 schrieb Gokulakannan Somasundaram: > > Hi, > > I am trying to filter out multi-line comments, for which i am using > the > > following Token definition (provided in antlr.org) > > ML_COMMENT > > > > : '/*' ( options { greedy = false; } : .* ) '*/' { skip(); }; > > > > I have done it like this: > in the lexer I added a member openComment: > > @member { > boolean openComment = false; > > //override nextToken: > @Override > public Token nextToken() { > Token t = super.nextToken(); > if (t == Token.EOF_TOKEN && openComment) { > System.err.println("gotcha!"); > } > return t; > } > > } > > > change your comment rule : > > ML_COMMENT > @init { openComment = true: } > : '/*' ( options { greedy = false; } : .* ) '*/' { openComment = > false; > skip(); }; > > > > > don't know if this is nice, but it works :-) > Michael > > --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
List: http://www.antlr.org/mailman/listinfo/antlr-interest Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address
