I just started with antlr, And I am using 4.2. Easy guessing says it would be like antlr3 in basics. so I followed the accepted answer of this question. (But instead of Exp, I replaced Java, which means I want to parse Java) Everything is fine, Until I want to compile the ANTLRDemo.java example.
When I compile that, I get 4 errors:
ANTLRStringStream in = new ANTLRStringStream("some random text");
JavaLexer lexer = new JavaLexer(in);
first error: constructor JavaLexer in class JavaLexer cannot be applied to given types; JavaLexer lexer = new JavaLexer(in); required: CharStream found: ANTLRStringStream reason: actual argument ANTLRStringStream cannot be converted to CharStream by method invocation conversion (I know what this error is ;-)
CommonTokenStream tokens = new CommonTokenStream( lexer); JavaParser parser = new JavaParser(tokens); System.out.println(parser.eval());
to make it short, let's say every line has its own similar error. For example, "parser" does not have an "eval()" method.
What am I missing? I guess antlr4 does not run like 3. Any Ideas? Please consider my beginner status.