[antlr-interest] test-java program not working

venkat medhaj hvmedhaj at gmail.com
Thu Feb 18 18:46:57 PST 2010


I found a Java 1.5 grammar that has the capability of building ASTs in the
website. I tried test running it against a simple Java Hello world
program...and I get the following error......
line 2:0 mismatched input 'public' expecting LCURLY
<mismatched token: [@0,2:7='public',<87>,2:0],
resync=publicclassTest{publicstaticvoidmain(String[]args){System.out.println("Helloworld...");}}>

>From what I see, it says it cant find a left curly brace after the public
keyword...but as a matter of fact, I did place that ...Can you please tell
me what could be the issue ?

BTW, here is my test case for that ...

package
a.b.c;
import
java.io.IOException;
import
org.antlr.runtime.*;
import
a.b.c.JavaTestParser.arrayInitializer_return;

public
class Test4 {
public static void main(String[] args) throws RecognitionException,
IOException {
// press F4 after highlighting charstream thingy CharStream charStream =
new ANTLRFileStream("C:/Test.java");
JavaTestLexer lexer =
new JavaTestLexer(charStream);
TokenStream tokenStream =
new CommonTokenStream(lexer);
JavaTestParser parser=
new JavaTestParser(tokenStream);
arrayInitializer_return tree=parser.arrayInitializer();
System.
out.println(""+tree.tree.toString());
System.
out.println("");
}
}
P.S: I was trying to play with this based on the tutorial that you showed me
the other day and its really interesting. I cant wait long to see the AST be
O/Ped...
-V


More information about the antlr-interest mailing list