dk.brics.grammar.ast
Class BranchNode

java.lang.Object
  extended by dk.brics.grammar.ast.Node
      extended by dk.brics.grammar.ast.BranchNode

public class BranchNode
extends Node

AST branch node.


Constructor Summary
BranchNode(BranchNode n, int to)
          Constructs a new AST node from an existing one by updating 'to'.
BranchNode(BranchNode n, String edge, Node m)
          Constructs a new AST node from an existing one by adding an edge.
BranchNode(ProductionID id, String name, int i, int j)
          Constructs a new AST node with no edges (yet).
 
Method Summary
 BranchNode getBranchChild(String name)
          Returns a branch child node.
 Node getChild(String name)
          Returns a child node.
 Set<String> getChildNames()
          Returns the set of child names in this node.
 String getLabel()
          Returns the production label of this node.
 String getLeafString(String name, AST t)
          Returns the substring of the leaf child of the given name.
 String getName()
          Returns the node name.
 ProductionID getProductionID()
          Returns the production ID.
 void print(String x, StringBuilder b)
          Prints this node.
 void replaceChild(String name, BranchNode n)
          Replaces an child with the children of another node.
 void visitBy(NodeVisitor v)
          Visits this node.
 
Methods inherited from class dk.brics.grammar.ast.Node
getFromIndex, getString, getToIndex
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BranchNode

public BranchNode(BranchNode n,
                  int to)
Constructs a new AST node from an existing one by updating 'to'.

Parameters:
n - existing node
to - to index

BranchNode

public BranchNode(BranchNode n,
                  String edge,
                  Node m)
Constructs a new AST node from an existing one by adding an edge.

Parameters:
n - existing node
edge - edge name
m - child node

BranchNode

public BranchNode(ProductionID id,
                  String name,
                  int i,
                  int j)
Constructs a new AST node with no edges (yet).

Parameters:
id - production ID
name - node name
i - from index
j - to index (not included)
Method Detail

getBranchChild

public BranchNode getBranchChild(String name)
                          throws ClassCastException
Returns a branch child node.

Parameters:
name - name of branch child node
Returns:
node, null if absent
Throws:
ClassCastException - if the child is not a branch node

getChild

public Node getChild(String name)
Returns a child node.

Parameters:
name - name of child node
Returns:
node, null if absent

getChildNames

public Set<String> getChildNames()
Returns the set of child names in this node.

Returns:
set of child names

getLabel

public String getLabel()
Returns the production label of this node.

Returns:
label

getLeafString

public String getLeafString(String name,
                            AST t)
                     throws ClassCastException
Returns the substring of the leaf child of the given name.

Throws:
ClassCastException - if the child is not a leaf node

getName

public String getName()
Returns the node name.

Returns:
name

getProductionID

public ProductionID getProductionID()
Returns the production ID.

Returns:
production ID

print

public void print(String x,
                  StringBuilder b)
Description copied from class: Node
Prints this node.

Specified by:
print in class Node
Parameters:
x - original string
b - string buffer for output

replaceChild

public void replaceChild(String name,
                         BranchNode n)
Replaces an child with the children of another node.

Parameters:
name - child to replace
n - node containing children to copy

visitBy

public void visitBy(NodeVisitor v)
Description copied from class: Node
Visits this node.

Specified by:
visitBy in class Node
Parameters:
v - visitor


Copyright © 2005-2008 Anders Møller.