[antlr-interest] Lazy load of CommonTokenStream??

Raphael Reitzig r_reitzi at cs.uni-kl.de
Mon Aug 18 05:07:23 PDT 2008


Hi Kay!

Why is LA(0) undefined? One could interpret LA(0) (and LB(0) as well)  
as looking ahead (back) zero steps, thus finding the current  
char/token. Would this be a problem of some kind? In fact, I would  
expect exactly this behaviour, because LA(1) yields the next char to  
the right and LA(-1) the next char to the left. As it is, I feel it's  
unnecessarily (?) non-continuous.

> 1) For CharStreams, LA(-1) will return CharStream.EOF. I think  
> that's at least inconsistent and should return INVALID_CHAR (which  
> doesn't exist right now), because it's not EOF, technically.
If you regard looking back as being equivalent to looking forward on a  
reversed stream, EOF makes sense. There _is_ end of "file", if not the  
right one.
I think it is consistent as it is. Looking out of char stream's bounds  
yields EOF.
Whats with LA(k), |k|>1? Is this handled properly when looking "past" EOF?

Regards

Raphel

----------------------------------------------------------------
This message was sent using IMP, the Internet Messaging Program.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 191 bytes
Desc: PGP Digital Signature
Url : http://www.antlr.org/pipermail/antlr-interest/attachments/20080818/da659c58/attachment.bin 


More information about the antlr-interest mailing list