[antlr-interest] java test case that I used

venkat medhaj hvmedhaj at gmail.com
Fri Feb 19 04:34:34 PST 2010


 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...");}}>

I get the above mentioned error when I tried running it against the Java 1.5
grammar which generates ASTs. Would anyone, please, explain me what the
problem is ?
I did make sure that I have a left curly brace placed in the right spot.
Here's my small little Test case.

*

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("");

}

}


-V


More information about the antlr-interest mailing list