[antlr-interest] Rewrite rule problem
Bart Kiers
bkiers at gmail.com
Mon Nov 5 11:14:50 PST 2012
What happens if you try:
qualified_open_type_name
: 'Global' (PERIOD identifier_or_keyword type_arity_list?)+
-> ^('Global' (^(PERIOD identifier_or_keyword type_arity_list?))+)
;
?
Regards,
Bart.
On Mon, Nov 5, 2012 at 2:39 PM, Roger Jack <rjack at elegancetech.com> wrote:
> Below are 3 rules from a grammar that I'm working on:
>
> Snippet qualified_open_type_name:
> 'Global' (PERIOD identifier_or_keyword type_arity_list?)+
> -> 'Global' ^(PERIOD identifier_or_keyword type_arity_list?)+;
>
> type_arity_list: OPEN_PARENTHESIS 'Of' comma_list? CLOSE_PARENTHESIS
> -> ^('Of' comma_list?);
>
> comma_list: COMMA+;
>
> When I call the qualified_open_type_name rule, I get the following results:
>
> input: Global.AnId1.AnId2
> tree: Global (. (ID AnId1)) (. (ID AnId2)) <- This is correct.
>
> input: Global.AnId1 (Of ,,,).AnId2
> tree: Global (. (ID AnId1) (Of , , ,)) (. (ID AnId2) (Of , , ,)) <-
> Incorrect. The last (Of , , ,) should not be there.
>
> Is my grammar incorrect? Is this a known bug? If it matters I'm using C#
> as the output language.
>
> Thanks!
>
> --
> Roger Jack
>
>
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe:
> http://www.antlr.org/mailman/options/antlr-interest/your-email-address
>
More information about the antlr-interest
mailing list