www.pudn.com > ParseAna.rar > AST.java


/** 
 * this class used for define the node information a node include six aspects 
 *  
 * @author:ºØ¾² 
 * @version 1.2 
 */ 
public class AST { 
	// the type of the node 
	private int type; 
 
	private String text; 
 
	// the child and the brother of the node 
	private AST down, right; 
 
	// the information for print 
	protected String info = ""; 
 
	protected boolean isLeaf = true; 
 
	public AST() { 
	} 
 
	public AST(boolean leaf) { 
		this.isLeaf = leaf; 
	} 
 
	public AST(int type) { 
		this.type = type; 
		this.down = this.right = null; 
	} 
 
	/** 
	 * @return a int as the type of the node 
	 */ 
	public int getType() { 
		return type; 
	} 
 
	public void setType(int type) { 
		this.type = type; 
	} 
 
	public String getText() { 
		return this.text; 
	} 
 
	public void setText(String text) { 
		this.text = text; 
	} 
/** 
 * @return the brother of current node 
 */ 
	public AST getRight() { 
		return this.right; 
	} 
/** 
 * @return the first child of current node 
 */ 
	public AST getDown() { 
		return this.down; 
	} 
	public void setRight(AST brother){ 
		this.right=brother; 
	} 
/** 
 * @param child 
 * add child to current token 
 */ 
	public void addChild(AST child) { 
		if (child == null) 
			return; 
		AST t = this.down; 
		if (t != null) { 
			while (t.right != null) { 
				t = t.right; 
			} 
			t.right = child; 
		} else { 
			this.down = child; 
		} 
	} 
}