[antlr-interest] How to read line/col from testLiteralsTable() ?

Daniel Zuberbuehler dzubi at users.sourceforge.net
Fri Sep 30 14:21:09 PDT 2005


Hi

I want to call a method every time the lexer matches a token in the literal 
table. So I override the testLiteralsTable() method. I first call 
super.testLiteralsTable() and check, if it was a match. If so, I call my 
method.
But for that method call, I need the line and col value of the keyword. 
Unfourtunately I see in the source of the generated lexer that makeToken() is 
called after testLiteralsTable(), so I can't query the token for those 
values. I also can't read the tokenStartColumn/tokenStartLine fields of the 
inputstate, as those are protected, and the CharScanner offers no methods to 
access those fields.
Is there any way to get those values? Or do you see a better approach?

Thanks and cheers,
Daniel Zuberbühler


More information about the antlr-interest mailing list