[antlr-interest] Re: Look-ahead changes when rules lifted up

mzukowski at yci.com mzukowski at yci.com
Tue Dec 3 13:35:56 PST 2002


> And how exactly does one do that (given that all the examples in the
documentation show changing lexers from the parser, e.g., Java/JavaDoc)?

Really?  The javadoc example in the examples/java/multiLexer only switches
lexers from a lexer.  Show me where the docs tell about switching lexers
from the parser.  There is a hard and fast rule that the parser can not talk
back to a lexer, so maybe the docs need changed to stress this point even
more.

>That aside, it doesn't answer my question since there should be no reason
why moving the code should change the behavior.

Moving the code changes what has been requested in the lookahead buffer.
Tokens are pulled on demand.

>Even that aside, for the '>' token, there is no reason it needs to
look-ahead at all since no other token starts with '>', i.e., it doesn't
need to look past it to disambiguate it.

But that is not how parsers work.  Rules are not methods.  They are not
independent of each other.  In fact they are dependent in ways that may seem
arbitrary until you understand lookahead computations.  Read Ter's thesis
for a good introduction to what is going on behind the scenes.


Monty

 

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



More information about the antlr-interest mailing list