[antlr-interest] Re: Local lookahead depth

John D. Mitchell johnm-antlr at non.net
Sat Nov 8 09:36:28 PST 2003


>>>>> "lgcraymer" == lgcraymer  <lgc at mail1.jpl.nasa.gov> writes:
[...Analysis lookahead vs. programmer lookahead vs. runtime lookahead...]

IMU, the biggest reason that the specification knob exists for setting k
equal to some number in Antlr is to help the Antlr analysis phase run
faster.  I.e., if you know that you only need k=2 then you can specify that
and antlr will run faster during it's analysis of the grammar.  Antlr,
modulo bugs, will generate exactly the same code for that grammar even if
you specify k=20 -- but antlr itself will take a lot longer to run.

I'm on the fence as to whether or not allowing the grammar developer to
explicitly specify the lookahead depth for e.g., a single rule is worth the
risks.  My gut says that it's just like the attempts to be able to
programmatically specify optimization rules -- all to often the programmer
is Just Plain Wrong(tm) (especially when you take into account code
modification by multiple developers over time).


> Also, as to actions in lookahead code: this is something that Ter
> supported in PCCTS under the name "guarded predicates" or some such.  I
> don't know that it saw much use, and I suspect that usage indicates a too
> early incorporation of semantic information into the translator--tree
> transformation helps avoid that.

Indeed.

The metaphor that I'm using is that of "successive refinement".  That is,
each phase refines the understanding of the input to greater levels of
precision.  As with any form of optimization, premature optimization is, as
the man says, the root of all evil in computer science.

Take care,
	John

 

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




More information about the antlr-interest mailing list