[antlr-interest] Problem with LT
Ric Klaren
klaren at cs.utwente.nl
Thu Sep 23 05:24:06 PDT 2004
On Mon, Sep 20, 2004 at 10:39:02AM +0200, Xavier Décoret wrote:
> I cannot find (I kow I saw it, but the search function is broken on the
> website) the documentation on LT()
Try and see if there's a comment describing it in the java code.
> 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.
LT(0) would refer to the token that has just now been read. E.g. it's not
doing what you want probably.
> 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?
Just tag the token:
i:id eq:EQUAL value { if (notExist(i) cout<<"Error on line" << eq->getLine(); }
Cheers,
Ric
--
-----+++++*****************************************************+++++++++-------
---- Ric Klaren ----- j.klaren at utwente.nl ----- +31 53 4893755 ----
-----+++++*****************************************************+++++++++-------
"Evil will always triumph, because Good is dumb." --- Spaceballs
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/antlr-interest/
<*> To unsubscribe from this group, send an email to:
antlr-interest-unsubscribe at yahoogroups.com
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
More information about the antlr-interest
mailing list