Advertisement
KillianMills

SimpleNode.java

Dec 12th, 2015
37
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.82 KB | None | 0 0
  1. /* Generated By:JJTree: Do not edit this line. SimpleNode.java Version 6.0 */
  2. /* JavaCCOptions:MULTI=true,NODE_USES_PARSER=false,VISITOR=true,TRACK_TOKENS=false,NODE_PREFIX=AST,NODE_EXTENDS=,NODE_FACTORY=,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */
  3. public
  4. class SimpleNode implements Node {
  5.  
  6.   protected Node parent;
  7.   protected Node[] children;
  8.   protected int id;
  9.   protected Object value;
  10.   protected Parser parser;
  11.  
  12.   public SimpleNode(int i) {
  13.     id = i;
  14.   }
  15.  
  16.   public SimpleNode(Parser p, int i) {
  17.     this(i);
  18.     parser = p;
  19.   }
  20.  
  21.   public void jjtOpen() {
  22.   }
  23.  
  24.   public void jjtClose() {
  25.   }
  26.  
  27.   public void jjtSetParent(Node n) { parent = n; }
  28.   public Node jjtGetParent() { return parent; }
  29.  
  30.   public void jjtAddChild(Node n, int i) {
  31.     if (children == null) {
  32.       children = new Node[i + 1];
  33.     } else if (i >= children.length) {
  34.       Node c[] = new Node[i + 1];
  35.       System.arraycopy(children, 0, c, 0, children.length);
  36.       children = c;
  37.     }
  38.     children[i] = n;
  39.   }
  40.  
  41.   public Node jjtGetChild(int i) {
  42.     return children[i];
  43.   }
  44.  
  45.   public int jjtGetNumChildren() {
  46.     return (children == null) ? 0 : children.length;
  47.   }
  48.  
  49.   public void jjtSetValue(Object value) { this.value = value; }
  50.   public Object jjtGetValue() { return value; }
  51.  
  52.   /** Accept the visitor. **/
  53.   public Object jjtAccept(ParserVisitor visitor, Object data)
  54. {
  55.     return visitor.visit(this, data);
  56.   }
  57.  
  58.   /** Accept the visitor. **/
  59.   public Object childrenAccept(ParserVisitor visitor, Object data)
  60. {
  61.     if (children != null) {
  62.       for (int i = 0; i < children.length; ++i) {
  63.         children[i].jjtAccept(visitor, data);
  64.       }
  65.     }
  66.     return data;
  67.   }
  68.  
  69.   /* You can override these two methods in subclasses of SimpleNode to
  70.      customize the way the node appears when the tree is dumped.  If
  71.      your output uses more than one line you should override
  72.      toString(String), otherwise overriding toString() is probably all
  73.      you need to do. */
  74.  
  75.   public String toString() {
  76.     return ParserTreeConstants.jjtNodeName[id];
  77.   }
  78.   public String toString(String prefix) { return prefix + toString(); }
  79.  
  80.   /* Override this method if you want to customize how the node dumps
  81.      out its children. */
  82.  
  83.   public void dump(String prefix) {
  84.     //System.out.println(toString(prefix)); // name of node
  85.     System.out.print(toString(prefix));
  86.     if (value != null){
  87.       System.out.print("("+ value + ")");
  88.     }
  89.     System.out.println();
  90.  
  91.     if (children != null) {
  92.       for (int i = 0; i < children.length; ++i) {
  93.         SimpleNode n = (SimpleNode)children[i];
  94.         if (n != null) {
  95.           n.dump(prefix + " ");
  96.         }
  97.       }
  98.     }
  99.   }
  100.  
  101.   public int getId() {
  102.     return id;
  103.   }
  104. }
  105.  
  106. /* JavaCC - OriginalChecksum=32e286140ad40be9ad5193b39e3c40e1 (do not edit this line) */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement