[antlr-interest] LT(0)

Braden McDaniel braden at endoframe.com
Sat Apr 5 23:36:41 PST 2003


On Sat, 2003-04-05 at 21:56, Terence Parr wrote:
> On Saturday, April 5, 2003, at 01:20  PM, Braden McDaniel wrote:
> 
> > On Thu, 2003-04-03 at 17:53, Terence Parr wrote:
> >> On Thursday, April 3, 2003, at 02:47  PM, mwwickline wrote:
> >>
> >>> I can't find anything in the documentation that explicitly states
> >>> whether you can do "LT(0)" and where it's allowed.  I'm getting a 
> >>> core
> >>
> >> LT(0) is meaningless, I'm afraid.  First symbol of lookahead is LT(1) 
> >> :)
> >
> > Hm... I've been using "LT(0)->getLine()" to get the current line 
> > number.
> 
> Is there a getLine() method in the lexer?  You could use that :)

There is, in fact. However, I don't see a way to get to it from inside
the parser. My lexer is a custom one that I derive from TokenStream.

It looks like I would have to add such a method to a class derived from
TokenBuffer; and instantiate the parser with that class in order to be
able to access this information from the parser. Does that sound right,
or is there a simpler way?

> Or LT(1).getLine().

But that looks ahead one token, so the line number could be different
from the current token... right?

-- 
Braden McDaniel                           e-mail: <braden at endoframe.com>
<http://endoframe.com>                    Jabber: <braden at jabber.org>


 

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




More information about the antlr-interest mailing list