KickJava   Java API By Example, From Geeks To Geeks.

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


1 package 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/RIGHTS.html
6  *
7  * $Id: //depot/code/org.antlr/main/main/antlr/collections/impl/ASTArray.java#4 $
8  */

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

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