lij.parserutil
Class TreeFactory
java.lang.Object
lij.parserutil.TreeFactory
public class TreeFactory
- extends java.lang.Object
This class is used by the parser to generate the tree structure that contains
the elements of a clause.
- Author:
- Nikolaos Chatzinikolaou
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
operatorStack
private java.util.Stack<Operator> operatorStack
rpn
private java.util.ArrayList<TreeNodeToken> rpn
TreeFactory
public TreeFactory()
pushTreeNodeToken
public void pushTreeNodeToken(TreeNodeToken token)
- Pushes a new token into the stack, and updtes the RPN (Reverse Polish
Notation) list accordingly.
- Parameters:
token
- The token to push.
purgeTreeStack
public void purgeTreeStack()
- Pops all of the remaining tokens from the stack into the RPN. This is equivalent to encountering the EOF operator (lowest precedence) when doing the RPN reordering. It is called AFTER the RPN reordering.
createTreeRoot
public TreeNode createTreeRoot()
- Converts the RPN list into a tree and returns the root node.
- Returns:
- The root node of the tree.