It is true that the parser can 'tune' to any channel. But you can't do
it while parsing. The channel should be set before parsing begins. If you want to see the off channel token while parsing, you can use LA( int ) and LT( int ) within the parser. For your example, you can write something like: end_statement : options { input.LA(1)==NEWLINE }?=> /*nothing*/ But what happens when there is a hidden token between 'options' and 'NEWLINE'. You can write a loop to ditch the hidden tokens and see if there is a new line following it but before the next 'DEFAULT' token. http://www.antlr.org/pipermail/antlr-interest/2009-April/033895.html The above link has an example of this implementation. It will recognize "foo<NEWLINE>" but not "foo" where <NEWLINE> is a hidden token. Hope that helps. Cheers, Indhu Iztok Kavkler wrote: The ANTLR reference claims that parser can tune to any channel, however I couldn't find any mention about how this can be done. What I'd like is to use grammar rule like this (or something equivalent):end_statement: options { channels = NEWLINES; } : NEWLINE ; Is something like this possible? 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-interest@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 -~----------~----~----~----~------~----~------~--~--- |
List: http://www.antlr.org/mailman/listinfo/antlr-interest Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address