[antlr-interest] Problem with LT

Xavier Décoret xdecoret at free.fr
Mon Sep 20 01:39:02 PDT 2004

I cannot find (I kow I saw it, but the search function is broken on the 
website) the documentation on LT()

In my parser, I have a rule like this:

i:id EQUAL value { if (notExist(i) cout<<"Error on line 
"<<LT(0)->getLine(); }

where EQUAL is a lexer token.

It creates segfault from times to times. I am not sure why I used LT(0). 
I think I believed (at the time I wrote this grammar) that LT(0) 
indicates the first token of the grammar rule.

Is that correct? Should I use LT(1) to refer to the EQUAL instead? Is it 
simply a bad practice to try to get a line number for a parser rule?

Thanks for explanations.

Yahoo! Groups Links

<*> To visit your group on the web, go to:

<*> To unsubscribe from this group, send an email to:
    antlr-interest-unsubscribe at yahoogroups.com

<*> Your use of Yahoo! Groups is subject to:

More information about the antlr-interest mailing list