[antlr-interest] Help with Null Pointer Exception

Naveen naveen.garg at gmail.com
Sat May 15 15:27:00 PDT 2010


On Mar 2, 1:01 am, swathy murthy <pskswa... at gmail.com> wrote:
>  the template is not executing. It
> is giving a Null Pointer Exception.

An alternative to
stat -> {$stat.st} ;  // for every stat[ement]
is
use rewrite in your grammar file
options {output=template;
	 rewrite=true;
	}
and use TokenReWriteStream instead of CommonTokenStream in the testrig
TokenRewriteStream tokens = new TokenRewriteStream(lexer);

See the /templates/rewriter/1pass example in the antlr book


More information about the antlr-interest mailing list