[antlr-interest] how to use Java arrays in rule argument actions in ANTLR v3

Christian Kohn ch.kohn at gmx.de
Wed Mar 14 01:32:07 PDT 2007

I use ANTLR v3 and want to generate Java code. If I want to use arrays 
as rule parameter or rule return value, ANTLR just ignores the square 
brackets of the array statements when generating Java code.

	dest returns [int[] value = new int[2]] : ... ;
	int dest() { int value = new int2; ... return value; }
instead of:
	int[] dest() { int[] value = new int[2]; ... return value;}

	add[int[] values] : ... ;
	void add(int values) { ... }
instead of:
	void add(int[] values) { ... }

thank you in advance!

More information about the antlr-interest mailing list