KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > persistence > antlr > collections > impl > ASTArray


1 package persistence.antlr.collections.impl;
2
3 /* ANTLR Translator Generator
4  * Project led by Terence Parr at http://www.jGuru.com
5  * Software rights: http://www.antlr.org/license.html
6  *
7  */

8
9 import persistence.antlr.collections.AST;
10
11 /** ASTArray is a class that allows ANTLR to
12  * generate code that can create and initialize an array
13  * in one expression, like:
14  * (new ASTArray(3)).add(x).add(y).add(z)
15  */

16 public class ASTArray {
17     public int size = 0;
18     public AST[] array;
19
20
21     public ASTArray(int capacity) {
22         array = new AST[capacity];
23     }
24
25     public ASTArray add(AST node) {
26         array[size++] = node;
27         return this;
28     }
29 }
30
Popular Tags