001/* Generated By:JJTree: Do not edit this line. SimpleNode.java Version 4.3 */ 002/* JavaCCOptions:MULTI=false,NODE_USES_PARSER=true,VISITOR=false,TRACK_TOKENS=false,NODE_PREFIX=AST,NODE_EXTENDS=,NODE_FACTORY=,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */ 003package ptolemy.data.expr; 004 005public class SimpleNode implements Node { 006 007 protected Node parent; 008 protected Node[] children; 009 protected int id; 010 protected Object value; 011 protected MatrixParser parser; 012 013 public SimpleNode(int i) { 014 id = i; 015 } 016 017 public SimpleNode(MatrixParser p, int i) { 018 this(i); 019 parser = p; 020 } 021 022 @Override 023 public void jjtOpen() { 024 } 025 026 @Override 027 public void jjtClose() { 028 } 029 030 @Override 031 public void jjtSetParent(Node n) { 032 parent = n; 033 } 034 035 @Override 036 public Node jjtGetParent() { 037 return parent; 038 } 039 040 @Override 041 public void jjtAddChild(Node n, int i) { 042 if (children == null) { 043 children = new Node[i + 1]; 044 } else if (i >= children.length) { 045 Node c[] = new Node[i + 1]; 046 System.arraycopy(children, 0, c, 0, children.length); 047 children = c; 048 } 049 children[i] = n; 050 } 051 052 @Override 053 public Node jjtGetChild(int i) { 054 return children[i]; 055 } 056 057 @Override 058 public int jjtGetNumChildren() { 059 return (children == null) ? 0 : children.length; 060 } 061 062 public void jjtSetValue(Object value) { 063 this.value = value; 064 } 065 066 public Object jjtGetValue() { 067 return value; 068 } 069 070 /* You can override these two methods in subclasses of SimpleNode to 071 customize the way the node appears when the tree is dumped. If 072 your output uses more than one line you should override 073 toString(String), otherwise overriding toString() is probably all 074 you need to do. */ 075 076 @Override 077 public String toString() { 078 return MatrixParserTreeConstants.jjtNodeName[id]; 079 } 080 081 public String toString(String prefix) { 082 return prefix + toString(); 083 } 084 085 /* Override this method if you want to customize how the node dumps 086 out its children. */ 087 088 public void dump(String prefix) { 089 System.out.println(toString(prefix)); 090 if (children != null) { 091 for (int i = 0; i < children.length; ++i) { 092 SimpleNode n = (SimpleNode) children[i]; 093 if (n != null) { 094 n.dump(prefix + " "); 095 } 096 } 097 } 098 } 099} 100 101/* JavaCC - OriginalChecksum=470141224a0ebddda32949289c2abc37 (do not edit this line) */