[antlr-interest] Using ANTLRv3
Stefan
jan_ek at op.pl
Fri May 4 02:18:01 PDT 2007
Hello!
I've been trying to use ANTLRv3, but it seems that I'm missing something.
I want to write a simple rule to match strings:
grammar Test;
string : '"' (~'"')+ '"';
D:\ANTLR\pliki>java org.antlr.Tool Test2.g
no such locale file org/antlr/tool/templates/messages/languages/pl.stg
retrying
with English locale
ANTLR Parser Generator Version 3.0b7 (April 12, 2007) 1989-2007
error(139): Test2.g:3:16: set complement ~'"' is empty
warning(201): Test2.g:3:19: The following alternatives are unreachable: 1
What's wrong? I guess that I only mention the '"' character, so the
complement is empty. How do I specify the character set?
I'm writing my grammar from a specification, so I'd like to make it look
as it's stated there, but trying to write a rule for an indentifier
gives lots of errors:
grammar Test3;
identifier
: nondigit (nondigit | digit)*;
nondigit: ('a'..'z') | ('A'..'Z') | '_';
digit : ('0'..'9');
D:\ANTLR\pliki>java org.antlr.Tool Test3.g
no such locale file org/antlr/tool/templates/messages/languages/pl.stg
retrying
with English locale
ANTLR Parser Generator Version 3.0b7 (April 12, 2007) 1989-2007
warning(200): Test3.g:4:30: Decision can match input such as "EOF" using
multipl
e alternatives: 1, 2, 3
As a result, alternative(s) 2,3 were disabled for that input
warning(200): Test3.g:4:30: Decision can match input such as "'_'" using
multipl
e alternatives: 1, 2
As a result, alternative(s) 2 were disabled for that input
warning(201): Test3.g:4:30: The following alternatives are unreachable: 2,3
warning(200): Test3.g:6:11: Decision can match input such as "'_'" using
multipl
e alternatives: 1, 2, 3
As a result, alternative(s) 2,3 were disabled for that input
warning(200): Test3.g:6:11: Decision can match input such as "EOF" using
multipl
e alternatives: 1, 2
As a result, alternative(s) 2 were disabled for that input
warning(201): Test3.g:6:11: The following alternatives are unreachable: 2,3
If I "inline" it like this:
identifier
: ('a'..'z' | 'A'..'Z' | '_') (('a'..'z' | 'A'..'Z' | '_') | '0'..'9')*;
Everything is OK. Why?
Is there going to be a complete and free documentation for ANTLRv3?
Stefan Chrobot
More information about the antlr-interest
mailing list