small medium large xlarge

Generic-user-small
10 Jun 2015, 12:31
Evgeni Petrov (2 posts)

I cannot compile the first snippet on page 26.

	ANTLRInputStream input = new ANTLRInputStream(System.in);

	ArrayInitLexer lexer = new ArrayInitLexer(input);		
	
	CommonTokenStream tokens = new CommonTokenStream((TokenSource) lexer);
	
	ArrayInitParser parser = new ArrayInitParser((TokenStream) tokens);
	
	ParseTree tree = parser.init();
	System.out.println(tree.toStringTree(parser)); ---

ArrayInitLexer wants CharStream and I cannot cast ANTLRInputStream to CharStream. I could not find another method that does that.

What am I missing here?

Generic-user-small
10 Jun 2015, 12:34
Evgeni Petrov (2 posts)

Ok, scratch that. Maybe eclipse was screwing with me. When I removed these:

import org.antlr.runtime.ANTLRInputStream; import org.antlr.runtime.CommonTokenStream; import org.antlr.runtime.TokenSource; — and left only — import org.antlr.v4.runtime.; import org.antlr.v4.runtime.tree.; — compiled.

I wonder what happened here but anyway.

You must be logged in to comment