[antlr-interest] Don't know some tree walker rules for specific parser rules
Gavin Lambert
antlr at mirality.co.nz
Mon Jul 14 13:20:44 PDT 2008
At 03:27 15/07/2008, Jens Boeykens wrote:
>What should be the walker rules for:
>
>A) r: (id -> id) ('+' id -> ^('+' r id))*;
>B) r: (id -> ^(ARG id)) ('+' id -> ^('+' $r id))*;
>C) r: (id -> ^(ARG id)) ('+' id -> ^('+' BLOCK id));
>
>My suggestions:
>A) r: id | ^('+' r id)*;
>B) r: ^(ARG id) | ^('+' r id)*;
>C) r: ^(ARG id) ^('+' BLOCK id);
>
>Are these correct? Note that first 2 rules are using recursion
>and the third does not.
Those look ok to me; except that the * probably ought to be a +,
since you don't want to match nothing at all. (The parser rule
can't generate an empty tree, after all.)
More information about the antlr-interest
mailing list