[antlr-interest] Inefficiency in lexer
Terence Parr
parrt at cs.usfca.edu
Fri May 27 13:52:26 PDT 2005
On May 27, 2005, at 12:19 PM, ttest wrote:
> Hi again,
>
> I'm not sure if Java is really that smart. I would think that LA(1) is
> compared to every character one at a time which would be inefficient.
>
> What would the lookup table look like?
>
> I guess the key in the table would be the char returned by LA(1)
> and what
> would the values be in that table? The memory location where execution
> continues?
>
> Then the lookup table would be 2^16*6=393216=390K bytes big which
> would be
> pretty much.
Java VMs claim to do a binary search for sparse data and a look up
table for contiguous data. In this case, binary search is the best
we can do with a switch. Sometimes an IF is better.
Ter
--
CS Professor & Grad Director, University of San Francisco
Creator, ANTLR Parser Generator, http://www.antlr.org
Cofounder, http://www.jguru.com
More information about the antlr-interest
mailing list