[antlr-interest] new action syntax proposal
Benjamin Niemann
pink at odahoda.de
Sat Jul 14 05:51:50 PDT 2007
Terence Parr wrote:
> Actions are not executed during backtracking as we cannot undo
> stateful actions. The problem is that some semantic predicates that
> test, for example, the symbol table rely on actions updating the
> symbol table during backtracking. I propose {...} stay same as an
> action but {{...}} (double curlies) implies always execute even when
> backtracking.
>
> Counterproposals?
I'd vote for "@always { ... }" or a similar keyword: exploit existing
syntax, use explicit keywords instead of adding more 'magic' characters.
And what about the 'undo' part? Or must the state changes be limited to
@scope stuff that can be reverted by ANTLR without user intervention?
Or did you think about stuff like "@init {{ ... }}". That would conflict
with the @always proposal. But a prefix could be used: "@always::init".
This could even be extended to
r
@always::init { change state }
@backtracking::after { revert state only in backtracking }
...
;
--
Benjamin Niemann
Email: pink at odahoda dot de
WWW: http://pink.odahoda.de/
More information about the antlr-interest
mailing list