[antlr-interest] Problems with Java 1.5 grammar
Ivan Dubrov
WFrag at yandex.ru
Fri Jun 24 11:06:18 PDT 2005
Hello,
I've tried to use one of the Java 1.5 grammars (this one:
http://www.antlr.org/grammar/1093454600181/java15-grammar.zip), but
encountered problems with the following code:
import java.io.StringReader;
public class Test {
public static void main(String[] args) throws Exception {
JavaLexer l = new JavaLexer(new StringReader("hello"));
JavaRecognizer r = new JavaRecognizer(l);
r.expression();
System.out.println("OK");
}
}
In my opinion, "hello" string is the Java expression, so the code should
print "OK". The grammar tells the same (although I'm not very good at
ANTLR grammars). But this code throws exception with message 'unexpected
token "hello"'.
Anybody can tell me what's the problem here? Anobody tried to use these
grammars to parse pieces of code?
Ivan.
More information about the antlr-interest
mailing list