[antlr-interest] executing actions during backtrack
Kay Roepke
kroepke at dolphin-services.de
Tue May 9 15:30:09 PDT 2006
On 9. May 2006, at 23:24 Uhr, Terence Parr wrote:
>
> On May 9, 2006, at 1:59 PM, Oliver Zeigermann wrote:
>
>> I guess you need something like an inverse action that applies when
>> backtracking fails. So you might need a pair of actions. This way all
>> actions executed inside backtracking are undone when backtracking is
>> done. Maybe it is enough to add an inverse action to indicate it
>> should be executed inside backtracking?
>
> Hi :) Yep, thought about that and decided it's probably very hard
> to always do an undo. That said, for symbol tables it might be
> doable. Might have to track stuff in a data structure to manage
> the undos. What if we did "software transaction" like stuff to
> auto-rewind?
Perl does something like that, but of course that only applies to
changes to locally scoped variables when you embed code in regexes.
Stacking those guessing code blocks and executing the undo blocks on
the way back would be the way to do, methinks.
If a user does something that absolutely should only happen once, one
would assume that he tests for guessing mode anyway. We can't second
guess them
there (as much as we wanted to ;))
-k
More information about the antlr-interest
mailing list