[antlr-interest] Re: Local lookahead depth

Oliver Zeigermann oliver at zeigermann.de
Mon Nov 10 21:31:24 PST 2003


Tom, 

thanks for that substantial post!

--- In antlr-interest at yahoogroups.com, Tom Moog <tmoog at p...> wrote:
> 
> I remember that John Lilley required the use of actions inside
> guess blocks to parse C++.  I believe that parsing some C++
> declarations which make use of nested classes might require
> symbol table additions that must be undone if the guess fails.
> Reasonable people may disagree about whether C++ is a real
> programming language or not (laugh).  He created a special
> version of pccts for this purpose.

I thought if a *formal* language is hard to parse than it might be
hard to read and understand by humans like us ;)

> The important thing to remember is that init-actions may be
> executed multiple times as back-tracking takes place.  Even if
> the first guess is correct, the init-action will be executed
> twice: once in guess mode and once in non-guess mode after
> the guess succeeds.  In the case where there is a guess
> within a guess, its quite possible that an init-action
> would be executed 4 times, etc.

This really is something to consider carefully. Maybe just as you
initialize everything at the beginning of a rule, there should be a
policy to undo everything at the end of a rule? Hmmm, which does not
work, as values must be present across multiple rules sometimes. What
if I said logical block instead of rule. Would that make sense?

Oliver


 

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




More information about the antlr-interest mailing list