On Wed, Sep 08, 2004 at 02:47:24PM -0400, JOSEPH RYAN wrote:
: We tried that as an optimization in the prototype 
: Perl6 compiler.  It ended up being a really really 
: really bad idea because the grammar backtracked like 
: a madman.  It might be workable if we can infuse 
: <commit>'s in every location possible...

I presume you mean the lower-level backtracking controls.  A <commit>
can only cause you to fail completely, and then only if you backtrack
over it.  (Or are you referring specifically to efficient error
recovery?)

Anyway, we'll try to write the grammar to minimize (and hopefully
eliminate) backtracking on any successful parse.  Might have to
generate some junctive parse states by hand until we can bring some
yacc-like analysis tools to bear on Perl grammars.  Backtracking may
turn out to be quite useful for trying to figure out what they *should*
have said so we can emit useful diagnostics, but we won't fall into
the PL/I trap of trying to "fix" their program on the fly for them.

So what we probably need is some <commit>-like thing that latches
to a bogus-compile state but continues to try to parse for a while.
Probably want a variant that also just throws away everything to the
end of the current statement if we can't figure anything useful out
by backtracking.  Even if the backtracking doesn't improve the primary
error message, it could usefully figure out that you were *trying*
to declare something of the name "foo", and maybe some of its traits,
so you don't get a mess of bogus cascaded errors based on the missing
declaration.

But let's crawl first.

Larry

Reply via email to