[antlr-interest] Returning from a sub-parser with no end token.

Remi Koutcherawy remi.koutcherawy at wanadoo.fr
Fri Dec 28 15:12:13 PST 2001

> I don't see what code you added...
Thanks Ter. I added an exception catch behind the protected filter Lexer Rule:

exception catch [NoViableAltForCharException ex]
 { throw new CharStreamException("EndToken"); }

This prevents the lexer from requesting a new char.

And behind the Parser rule I added another exception catch :
parse: (B)+ (BBB!)?  ;
exception catch [antlr.TokenStreamException ex]
 { parse_AST = (AST)currentAST.root; }

This catches the exception I raised in the lexer (which is transformed
from CharStreamException to TokenStreamException) and adds the code
lacking because not executed at the end of the try { }.

> basically if you make a sentinel token optional a lexer has a problem
> switching back to another lexer.  It has to get a token to test it (to
> see if it's BBB), right?  If not BBB then it is incorrectly accessing
> the stream of chars associated with the other lexer.
> Ter

I try to parse JJYY, and KKXX messages. You may have a glimpse at :

I try to figure which one I receive in the main parser and then I switch to a specific parser and
The issue is that they end with no sentinel token.

May be you have another suggestion for how to use ANTLR to decode these messages ?



Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 

More information about the antlr-interest mailing list