예제 #1
0
  public ParseNode addChild(String newlabel) {

    ParseNode child = new ParseNode(newlabel, -1);
    children.addElement(child);
    child.setParent(this);
    return child;
  }
예제 #2
0
 public String getTerminal() {
   ParseNode pn = children.elementAt(0);
   if (pn == null) {
     return null;
   } else {
     return pn.getLabel();
   }
 }
예제 #3
0
  public ParseNodeVector getChildren(String label) {
    int i;
    ParseNodeVector v = new ParseNodeVector();

    for (i = 0; i < children.size(); i++) {
      ParseNode pn = children.elementAt(i);
      if (pn.getLabel().equals(label)) v.addElement(pn);
    }

    return v;
  }
예제 #4
0
  public ParseNode getChild(String label) {
    int i;
    ParseNode p;

    for (i = 0; i < children.size(); i++) {
      p = children.elementAt(i);
      if (p.getLabel().equals(label)) {
        return p;
      }
    }

    return null;
  }
예제 #5
0
  public ParseNode addChild(ParseNode child) {

    if (child == null) throw new NullPointerException("Can't add null node to parse tree");

    children.addElement(child);
    child.setParent(this);
    return child;
  }
예제 #6
0
  public ParseNode insertChild(ParseNode child) {
    if (child == null) {
      throw new NullPointerException("Can't add null node to parse tree");
    }

    children.insertElementAt(child, 0);
    child.setParent(this);
    return child;
  }
예제 #7
0
 public int getLine() {
   if (line >= 0) {
     return line;
   } else {
     if (parent != null) {
       return parent.getLine();
     } else {
       return 0;
     }
   }
 }
예제 #8
0
 public ParseNode getRoot() {
   return (parent == null) ? this : parent.getRoot();
 }