[antlr-interest] v3: using literals
Jeff Barnes
Jeff.Barnes at codesic.com
Tue Mar 7 10:23:59 PST 2006
Put protected in front of the two rules called by typeSpec.
________________________________
From: antlr-interest-bounces at antlr.org on behalf of Dieter Frej
Sent: Tue 3/7/2006 10:09 AM
To: antlr-interest Interest
Subject: Re: [antlr-interest] v3: using literals
Thanks Ter! Is there any way I can get rid of this ambiguity?
... or anyone else besides Ter? ;-)
- Didi
Terence Parr wrote:
> Hi. The grammar you have is fine minus the ambiguity. You don't need
> to do that testLiterals stuff with v3. It just works.
>
> Ter
>
> On Mar 5, 2006, at 7:44 AM, Dieter Frej wrote:
>
>> Hi,
>>
>> since antlrworks is a nice program I started using it (in my case it
>> does not matter whether I use antlr v2 or v3).
>>
>> I have something pretty easy such as
>>
>> typeSpec
>> :
>> (classOrInterfaceType | primitiveType)
>> ;
>>
>> primitiveType
>> : //
>> | 'boolean'
>> | 'byte'
>> | 'char'
>> | 'short'
>> | 'int'
>> | 'float'
>> | 'long'
>> | 'double'
>> ;
>>
>> classOrInterfaceType
>> : //
>> IDENT
>> ;
>>
>> IDENT
>> : ('a'..'z'|'A'..'Z'|'_'|'$')
>> ('a'..'z'|'A'..'Z'|'_'|'0'..'9'|'$')*
>> ;
>>
>> I am getting a
>>
>> [16:32:58] test.g:47:9: Decision can match input such as "IDENT" using
>> multiple alternatives: 1, 2
>> As a result, alternative(s) 2 were disabled for that input
>>
>> which I completly understand. The problem is that I do not know how to
>> use and test for literals in antlr v3. I did put
>>
>> grammar test;
>> options {
>> output = AST;
>> }
>> tokens {
>> LITERAL_boolean='boolean';
>> LITERAL_byte='byte';
>> LITERAL_char='char';
>> LITERAL_short='short';
>> LITERAL_int='int';
>> LITERAL_float='float';
>> LITERAL_long='long';
>> LITERAL_double='double';
>> }
>>
>> in my grammar, but when I put testLiterals=true under options, it keeps
>> complaining. I searched for it on the web page, but nothing :-/ Not even
>> in the java example grammar that is on the v3 page.
>>
>> Any hints/suggestions how I could do that in v3? Or is v3 not yet ready
>> for that?
>> If so: is there any other nice visual development tool for antlr v2?
>>
>> Didi
>
>
>
More information about the antlr-interest
mailing list