[antlr-interest] change token type?

Kendall Shaw kshaw at kendallshaw.com
Fri Jul 31 17:20:59 PDT 2009


"Kevin J. Cummings" <cummings at kjchome.homeip.net> writes:

> On 07/31/2009 07:31 PM, Kendall Shaw wrote:
>> Here's my non-working toy grammar:
>> 
>> grammar test;
>> 
>> tokens {
>>     CAT = 'cat' ;
>>     LP = '(' ;
>>     RP = ')' ;
>> }
>> 
>> them
>>     : (cat)=> cat
>>     | NAME
>>     ;
>
> Have you tried:
>
> them : (CAT LP)=> cat
>      | name;
>
> name : NAME
>      | CAT;

Thanks! I had tried something like the name rule there from the FAQ,
but I missed that it was a parser rule, and got ambiguity errors.

Kendall


More information about the antlr-interest mailing list