net.scheinerman.phoenix.interpreter.parser
Interface ParserTreeNode

All Known Implementing Classes:
AddOperatorNode, AndOperatorNode, ArgListNode, AssignAddOperatorNode, AssignDivideOperatorNode, AssignExpOperatorNode, AssignModOperatorNode, AssignMultiplyOperatorNode, AssignOperatorNode, AssignRoundOperatorNode, AssignSubtractOperatorNode, DataNode, DivideOperatorNode, EqualOperatorNode, ExpOperatorNode, FunctionOperatorNode, FunctionReferenceOperatorNode, GreaterEqualOperatorNode, GreaterOperatorNode, LessEqualOperatorNode, LessOperatorNode, ModOperatorNode, MultiplyOperatorNode, NegationOperatorNode, NotEqualOperatorNode, NotOperatorNode, OperatorNode, OrOperatorNode, PostfixDecrementOperatorNode, PostfixIncrementOperatorNode, PrefixDecrementOperatorNode, PrefixIncrementOperatorNode, RoundOperatorNode, SubscriptSliceOperatorNode, SubtractOperatorNode, XOrOperatorNode

public interface ParserTreeNode

Represents a node that is part of the parsing of an expression tree in Phoenix. When Phoenix parses an expression, the values, operators and functions are combined into a mostly binary tree which is then parsed to obtain the value of the expression. This parsing is done via the operate() method. This method is implemented to return the value of a variable or perform the operations of the left and right subtrees.

Since:
1.5
Version:
1.0
Author:
Jonah Scheinerman

Field Summary
static boolean parenthesized
          Whether or not this node was encapsulated by parentheses.
 
Method Summary
 int getPrecedence()
          Returns the precedence of the node in the order of operations, when it should be evaluated in the tree.
 boolean isParenthesized()
          Returns true or false based on whether or not this node was encapsulated by parentheses.
 ParserTreeNode left()
          Should be implemented to return the left child node of the current node.
 Variable operate()
          Operates on this node to provide some sort of variable result dependent on the expression being parsed.
 ParserTreeNode right()
          Should be implemented to return the right child node of the current node.
 void setParenthesized(boolean parenthesized)
          Sets whether or not this node is encapsulated by parentheses.
 

Field Detail

parenthesized

static final boolean parenthesized
Whether or not this node was encapsulated by parentheses.

See Also:
Constant Field Values
Method Detail

left

ParserTreeNode left()
Should be implemented to return the left child node of the current node.

Returns:
The left child (the left-hand operand).

right

ParserTreeNode right()
Should be implemented to return the right child node of the current node.

Returns:
The left child (the right-hand operand).

operate

Variable operate()
Operates on this node to provide some sort of variable result dependent on the expression being parsed.

Returns:
A variable that is the parsed version of this expression.

getPrecedence

int getPrecedence()
Returns the precedence of the node in the order of operations, when it should be evaluated in the tree. The precedence is an integer, the higher the integer, the higher the precedence, meaning that this node will be evaluated sooner than those of lower precedence.

Returns:
A number representing the precedence of this node.

isParenthesized

boolean isParenthesized()
Returns true or false based on whether or not this node was encapsulated by parentheses.

Returns:
Whether or not this node was encapsulated by parentheses.

setParenthesized

void setParenthesized(boolean parenthesized)
Sets whether or not this node is encapsulated by parentheses.

Parameters:
parenthesized - - true if this node is surrounded by parentheses, false if not.