[antlr-interest] executing actions during backtrack

Terence Parr parrt at cs.usfca.edu
Thu May 11 10:42:18 PDT 2006


On May 10, 2006, at 1:46 AM, Loring Craymer wrote:

> This is really one of those situations where building a solution  
> into ANTLR
> is probably a mistake: simplicity is a virtue.  As a user, you can  
> always do
> something like
>
> { saveState(); } (synpred) => <grammar fragment>
> | { recover(); } <alt fragment>
>
>
> if you ever encounter a situation where a rollback is really  
> needed.  I've
> never seen a case where that was true, although I have done the  
> "wouldn't it
> be nice" thinking.  Like everyone else, I sometimes try to provide  
> solutions
> to non-problems and regret it later.
>
> Does anyone out there have an example that justifies the  
> implementation
> effort?  That would probably be good to know before Ter does the work.

Yep, coming to the conclusion that it's only symbol table stuff that  
needs to go in and that naturally unrolls itself...IF actions are  
executed.  Currently there is no way to specify that an action must  
execute even when backtracking.  That we still need a suggestion  
for.  I almost wonder if it's a global flag like "always exec  
actions" and then if you need a few not-executed, you can manually  
gate with "if ( !guessing )".

Hmm....

Ter



More information about the antlr-interest mailing list