[antlr-interest] Re: Local lookahead depth

Tom Moog tmoog at polhode.com
Mon Nov 10 22:23:45 PST 2003


For C++ you could use an object with a dtor.

I seem to remember that pccts allows one to associate
user-defined routines with the guess-success and
guess-fail so that one can undo or commit depending
on the guess outcome.



On Tue, 11 Nov 2003, Oliver Zeigermann wrote:

> 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/
>
>

 

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




More information about the antlr-interest mailing list