|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.agentfactory.common.parser.Node
public class Node
This class implements a node in the parse tree that is generated by the parsing process. Each individual node in the parse tree holds a token and a handler that is delegated the visitor handling responsibility for that node (this has allowed us to maintain only one Node type rather than having to generate a different type of node for each token in the language). Each node also maintains a list of children nodes in the tree. Currently, some nodes may include only a handler. These are normally abstract nodes that are used to deal with cases where the underlying handler must deal with multiple problems. For example: a FOS can be both part of a statement and a statement in its own right. This causes problems with some of the visitors. TODO (Rem Collier): An alternative may be to subclass the FOSHandler in this case - must investigate.
| Constructor Summary | |
|---|---|
Node(Handler handler)
Construct a node with only a handler |
|
Node(Token token,
Handler handler)
Construct a node object with a given token and handler/ |
|
| Method Summary | |
|---|---|
void |
accept(Visitor visitor)
Method that accepts incoming visitor objects that are in the process of traversing the tree. |
void |
addChild(Node node)
Add a child node to a given node. |
Node |
childAt(int index)
Accessor that returns the child node at a given position in the children list. |
java.util.List<Node> |
getChildren()
Accessor method that returns the children of this node. |
Token |
getToken()
Accessor method that returns the token. |
boolean |
hasChildren()
Accessor method that checks whether of not the node has children |
java.lang.String |
toString()
Returns a string representation of the node. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public Node(Token token,
Handler handler)
token - the token that the node representshandler - the handler for that tokenpublic Node(Handler handler)
handler - the handler for that token| Method Detail |
|---|
public void addChild(Node node)
node - the child node to be added.public Token getToken()
public java.util.List<Node> getChildren()
public boolean hasChildren()
public Node childAt(int index)
index - the index of the child node to be returned
public java.lang.String toString()
toString in class java.lang.Object
public void accept(Visitor visitor)
throws SemanticError
visitor - a visitor object that is traversing the tree
SemanticError
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||