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

Marcin Rzeźnicki marcin.rzeznicki at gmail.com
Mon May 3 05:33:30 PDT 2010


On Mon, May 3, 2010 at 1:47 AM, Terence Parr <parrt at cs.usfca.edu> wrote:
>
> On May 2, 2010, at 4:42 PM, Marcin Rzeźnicki wrote:
>> ah, thanks a lot - that explains a lot
>> So, in th example you posted above - with an action in front it is
>> equivalent to:
>> a : {action} ID
>>  | ID
>> ;
>> right?
>
> yup.
>
>> So, care to give me any hint about reorganizing actions in similar
>> case? Thx a lot
>
> move the pred to the left of action. ;) if function of action, move code into pred.
> T
>

Hi again,
Thanks to your advice I was able to resolve my problems, yet I think
that ANTLR is buggy in one aspect. If I understand this correctly:
during evaluation of semantic predicates  actions are not executed, so
if the action is in front of a predicate, behavior of parser may be
inconsistent - parsing and backtracking modes might take different
routes due to action's side effect. But, if actions is marked as '{{'
which means execute regardless of backtracking then, following the
reasoning above, it should not hide following predicates because
anything this action can do wrt. changing parsing state will be
visible in both 'modes' and behavior of parsing will be consistent.
But ANTLR still hides predicate, even if action is '{{'.



-- 
Greetings
Marcin Rzeźnicki


More information about the antlr-interest mailing list