[antlr-interest] catching an exception in the parser and continuing - will this work?
davidjpenton2002 <djplists at arrowsash.com>
djplists at arrowsash.com
Fri Jan 24 07:32:23 PST 2003
I am handling "include files" in my lexer, as in the java example
provided with antlr. This means that fact the lexer is in an
included file is transparent to the parser.
However, it turns out that I want the parser to be made aware of the
fact that the lexer is in an included file. (Kindly assume that I
have a sound design reason for this ;-) Given the amount of lookahead
that may occur, I am sure that the only safe way to do this is by
putting the correct "notification" on the stream of tokens passed to
the parser.
Is it possible to have the lexer pass a back a "bad" token (i.e. one
that the parser can never recognize), catch a resultant exception,
and then (here's the important part) force the parser to take up
right where is was when it got the "bad" token? It would amount to
skipping over the "bad" token, except that the exception handling
code would set a flag or two that would be available later to parser
semantic actions.
I have looked at the exception handling documentation, and sifted
through my generated parser. It is not clear to me if my strategy
will work.
BTW, I am still using antlr 2.7.1 - I want to try to finish what I am
doing before trying the switch to 2.7.2.
Thanks.
- Dave Penton -
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
More information about the antlr-interest
mailing list