[antlr-interest] problem with line numbers in 2.7.2

mzukowski at yci.com mzukowski at yci.com
Wed Jun 25 08:25:42 PDT 2003


Are you using the gcc lexer?  Sounds like you need to add a getLine() method
to the lexer that uses the lineObject.  I hadn't caught that before, I'll
add it to the source when I get a chance.

Thanks!

Monty

-----Original Message-----
From: atripp54321 [mailto:atripp at comcast.net] 
Sent: Tuesday, June 24, 2003 8:40 PM
To: antlr-interest at yahoogroups.com
Subject: [antlr-interest] problem with line numbers in 2.7.2


Hi,

I just upgraded to antlr 2.7.2 because I want the 
enhancement that a RecognitionException will show a line number. 
Every time I get a RegocnitionException
in my lexer, it shows line number 1.

A quick look at my generated lexer code shows getLine() 
is called to get the line number whenever a NoViableAltException 
is created:
	throw new NoViableAltForCharException((char)LA(1), 
	getFilename(), getLine(), getColumn());

And it looks like there is now a LineObject object 
in my lexer, and THAT is where the true line number is being kept 
(being incremented by the newline() method, for example).  
However, there is no getLine() function in my lexer, it inherits the one
from CharScanner, which is getting the line number from 
somewhere else.

And, sure enough, if I replace each getLine() call with 
"lineObject.line", I get the proper line number.

Is this a bug? I apologize in advance if it's already been discussed.

Thanks,
Andy


 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 


 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 




More information about the antlr-interest mailing list