[antlr-interest] Rewrite rule problem

Roger Jack rjack at elegancetech.com
Mon Nov 5 12:07:20 PST 2012


Bart,

Thanks for the reply! I tried both

      -> ^('Global' (^(PERIOD identifier_or_keyword type_arity_list?))+)

and

      -> 'Global' (^(PERIOD identifier_or_keyword type_arity_list?))+

and still had the same problem with type_arity_list.

Any other suggestions?
*
Roger Jack*
On 11/5/2012 2:14 PM, Bart Kiers wrote:
> 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 
> <mailto: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