[antlr-interest] v3: using literals
Dieter Frej
dieter_frej at gmx.net
Sun Mar 5 07:44:10 PST 2006
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