[antlr-interest] Actions and non-LL(*) rules ??

Marcin Rzeźnicki marcin.rzeznicki at gmail.com
Mon May 3 10:08:52 PDT 2010


2010/5/3 Terence Parr <parrt at cs.usfca.edu>:
> it still won't execute the {{...}}} before the pred is evaluated during
> prediction. it must not eval disambiguating preds after actions in any
> circumstance.
> Ter

I see. So that poses yet another problem with recursive tree-like
definitions. If I got production like

s returns[Tree tree]
:
a1=a {$tree = $a1.tree; }  (DELIMITER a2=a {$tree = new Tree($tree,$a2.tree);})*

AND there is an ambiguity in whether to enter the loop or leave it (it
creates predicate under the hood) then the first action hides that
predicate. Then the solution is to explicitly check in the second
action whether current iteration is the first one, which is pretty
ugly and imposes performance hit as this means that this test is
repeated on every loop roll, or unroll the loop manually one time
which is ugly too :-/ I suppose there is no syntax which marks an
action as predicate-safe? :-)

-- 
Greetings
Marcin Rzeźnicki


More information about the antlr-interest mailing list