lij.parserutil
Class TreeFactory

java.lang.Object
  extended by 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

Field Summary
private  java.util.Stack<Operator> operatorStack
           
private  java.util.ArrayList<TreeNodeToken> rpn
           
 
Constructor Summary
TreeFactory()
           
 
Method Summary
 TreeNode createTreeRoot()
          Converts the RPN list into a tree and returns the root node.
 void purgeTreeStack()
          Pops all of the remaining tokens from the stack into the RPN.
 void pushTreeNodeToken(TreeNodeToken token)
          Pushes a new token into the stack, and updtes the RPN (Reverse Polish Notation) list accordingly.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

operatorStack

private java.util.Stack<Operator> operatorStack

rpn

private java.util.ArrayList<TreeNodeToken> rpn
Constructor Detail

TreeFactory

public TreeFactory()
Method Detail

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.