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

Peggy Fieland madcapmaggie at yahoo.com
Mon Oct 3 06:50:39 PDT 2005


Since ANTLR is open source, I'd just add the methods I
needed.

--- Daniel Zuberbuehler <dzubi at users.sourceforge.net>
wrote:

> Hi 
> 
> too bad I've got no feedback for my problem. However
> I've found a solution, I 
> just call super.makeToken() myself and query the
> instantiated token for it's 
> line/column values. I belief this should have no
> sideeffects, but it seems 
> not very elegant to me to instantiate a token just
> to access the line/col 
> values. So if anyone knows a direct way to access
> these values, I'd 
> appreciate to hear from you.
> 
> Cheers, Daniel
> 
> 
> On Friday 30 September 2005 23:21, Daniel
> Zuberbuehler wrote:
> > 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