[antlr-interest] skipping input to newline character
dvromano
dromano at attglobal.net
Fri Nov 22 15:23:20 PST 2002
I have a line oriented grammar. Under some conditions determined only
after matching a pattern in the parser, I want to discard the
reminder of the line. In most cases, the contents of the remainder of
the line contains arbitrary characters and symbols.
I tried to use: consumeUntil('\n') but I get an occasional
TokenStreamRecognitionException on a character or symbol not
expected. In additon, what I presume to be the input character
pointer does not advance past that point. (not sure exactly how it
works:-))
How do I advance past the unwanted characters, until the newline
character is reached, based on a decision made while parsing?
In JavaCC I would use an alternative scanner (lexer) state to define
all characters that are not a newline as skip characters. Can I put
the ANTLR lexer into an alternative state similar to JavaCC? How?
Can't use facilities from the lexer (ie. setting token type
to 'antlr::Token::SKIP') as the characters/symbols are valid in
normal context.
Help would be greatly appreciated.
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
More information about the antlr-interest
mailing list