[antlr-interest] [newbie] Precedence of rules

Robert Munteanu robert.munteanu at gmail.com
Wed Jul 9 07:44:24 PDT 2008


Johannes, Felix - thank you for your help. That fixed it.

Robert

2008/7/9 Felix Dorner <felix_do at web.de>:
> Hi Robert.
>>
>> startup:
>>  first=STRING COMMA second=STRING
>>  {
>>    System.out.println($first.text + " and " + $second.text);
>>  }
>> ;
>>
>> COMMA : ',';
>> STRING : ('a'..'z'|'A'..'Z')+;
>>
>
>> STRING_WITH_COMMA : STRING (COMMA STRING)+ ;
>>
>>
>
> I am pretty sure this rule bites with the "startup" rule. I am also pretty
> sure that you would not want this to be a Lexer but a Parser rule (i.e.
> should start with a lower Case.) Then you would have:
>
> startup: STRING COMMA STRING {...};
>
> string_with_comma: STRING (COMMA STRING)+;
>
>
> Now it depends how those rules are invoked. If they have a common
> "superrule", then the grammar would be ambiguous.
>
>
>
> Felix
>
>
>
>
>
>


More information about the antlr-interest mailing list