Can a parser tell the lexer to ignore a newline?

Posted by chollida on Stack Overflow See other posts from Stack Overflow or by chollida
Published on 2010-06-17T20:10:18Z Indexed on 2010/06/17 20:33 UTC
Read the original article Hit count: 148

Filed under:

I'm writing a preprocessor for my language. In the preprocessor I've output a line that wasn't in the source file. This causes any error messages that Anltr creates to be incremented by one line.

The Lexer handles the line count so I'm wondering if there is a way for the parser to tell the lexer to decrement the line count, or to ignore a specific newline.

I'm also open to other suggestions on how to work around this.

The only constraint I have is putting the extra line inline with the existing code. I'd prefer to keep it on it's own line to keep my parsing sane.

© Stack Overflow or respective owner

Related posts about antlr