tags:

views:

25

answers:

1

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.

A: 

What if you remove the pre-processor line and replace it with the new line instead of adding a new one? Then parse the output of the pre-processor.

justin.m.chase
I'm not sure I understand your response. The preprocessor is adding an additional line to a file that the regular language parser has to parse. This causes the line number to be off in messages generated by Antlr.
chollida