[antlr-interest] Re: Local lookahead depth

Oliver Zeigermann oliver at zeigermann.de
Mon Nov 10 23:44:13 PST 2003


--- In antlr-interest at yahoogroups.com, Tom Moog <tmoog at p...> wrote:
> 
> For C++ you could use an object with a dtor.

Sure, but when to delete the object. Same problem as with Java, it
seems :(
 
> 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.

Sounds good, but probably would be the source for lots of bugs. My
dream would be some sort of transaction that simply gets rolled back
when guessing failes. Although, this will remain a dream for some
time ;)

Oliver

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




More information about the antlr-interest mailing list