[antlr-interest] How do I accept input ending with a newline *or* EOF?
Micha
micha-1 at fantasymail.de
Sat Feb 5 08:26:55 PST 2011
you could also override the nextToken method in your lexer class to overread
tokens until a flag (maybe skip) becomes false:
. at Override
.Token nextToken() {
. do {
. Token = super.nextToken();
. } while (skip == true || token == #if | token == #endif );
. return token;
.}
And in your lexer rules for '#if' and '#endif' you set skip according to the
expression result. And you have to parse your expression to do that. So after
reading the text after '#if' until the end of the line, parse this text to get
the result and set your flag.
cheers
Michael
More information about the antlr-interest
mailing list