AST node representing a binary operator. More...
Public Member Functions | |
| __construct ($left, $operator=null, $right=null) | |
| Constructor. More... | |
| getLeft () | |
| Return the first (left) operand. More... | |
| setLeft ($operand) | |
| Set the left operand. More... | |
| getOperator () | |
| Return the operator. More... | |
| setOperator ($operator) | |
| Set the operator. More... | |
| getRight () | |
| Return the second (right) operand. More... | |
| setRight ($operand) | |
| Set the right operand. More... | |
| getPrecedence () | |
| Return the precedence of the ExpressionNode. More... | |
| accept (Visitor $visitor) | |
| Implementing the Visitable interface. | |
| canBeUnary () | |
| Returns true if the node can represent a unary operator, i.e. More... | |
| lowerPrecedenceThan ($other) | |
| Returns true if the current Node has lower precedence than the one we compare with. More... | |
| strictlyLowerPrecedenceThan ($other) | |
| compareTo ($other) | |
| Implementing the compareTo abstract method. More... | |
Public Member Functions inherited from MathParser\Parsing\Nodes\Node | |
| compareTo ($other) | |
| Helper function, comparing two ASTs. More... | |
| evaluate ($variables) | |
| Convenience function for evaluating a tree, using the Evaluator class. More... | |
| complexity () | |
| Rough estimate of the complexity of the AST. More... | |
| isTerminal () | |
| Returns true if the node is a terminal node, i.e. More... | |
| getOperator () | |
| __toString () | |
Public Attributes | |
| const | LEFT_ASSOC = 1 |
| integer constant representing left associatve operators | |
| const | RIGHT_ASSOC = 2 |
| integer constant representing left associatve operators | |
Public Attributes inherited from MathParser\Parsing\Nodes\Node | |
| const | NumericInteger = 1 |
| const | NumericRational = 2 |
| const | NumericFloat = 3 |
Private Attributes | |
| $left | |
| Node $left Left operand. | |
| $operator | |
| string $operator Operator, e.g. More... | |
| $right | |
| Node $right Right operand. | |
| $precedence | |
| int $precedence Precedence. More... | |
| $associativity | |
| LEFT_ASSOC | RIGHT_ASSOC $associativity Associativity of operator. More... | |
Additional Inherited Members | |
Static Public Member Functions inherited from MathParser\Parsing\Nodes\Node | |
| static | rationalFactory (Token $token) |
| Node factory, creating an appropriate Node from a Token. More... | |
| static | factory (Token $token) |
| Node factory, creating an appropriate Node from a Token. More... | |
AST node representing a binary operator.
| MathParser\Parsing\Nodes\ExpressionNode::__construct | ( | $left, | |
$operator = null, |
|||
$right = null |
|||
| ) |
Constructor.
Construct a binary operator node from (one or) two operands and an operator.
For convenience, the constructor accept int or float as operands, automatically converting these to NumberNodes
| MathParser\Parsing\Nodes\ExpressionNode::canBeUnary | ( | ) |
Returns true if the node can represent a unary operator, i.e.
if the operator is '+' or '-'-
| boolean |
| MathParser\Parsing\Nodes\ExpressionNode::compareTo | ( | $other | ) |
Implementing the compareTo abstract method.
| MathParser\Parsing\Nodes\ExpressionNode::getLeft | ( | ) |
Return the first (left) operand.
| Node|null |
| MathParser\Parsing\Nodes\ExpressionNode::getOperator | ( | ) |
Return the operator.
| string |
| MathParser\Parsing\Nodes\ExpressionNode::getPrecedence | ( | ) |
Return the precedence of the ExpressionNode.
| int | precedence |
| MathParser\Parsing\Nodes\ExpressionNode::getRight | ( | ) |
Return the second (right) operand.
| Node|null |
| MathParser\Parsing\Nodes\ExpressionNode::lowerPrecedenceThan | ( | $other | ) |
| MathParser\Parsing\Nodes\ExpressionNode::setLeft | ( | $operand | ) |
Set the left operand.
| void |
| MathParser\Parsing\Nodes\ExpressionNode::setOperator | ( | $operator | ) |
Set the operator.
| void |
| MathParser\Parsing\Nodes\ExpressionNode::setRight | ( | $operand | ) |
Set the right operand.
| void |
|
private |
LEFT_ASSOC | RIGHT_ASSOC $associativity Associativity of operator.
|
private |
string $operator Operator, e.g.
'+', '-', '*', '/' or '^'
|
private |
int $precedence Precedence.
Operators with higher prcedence bind harder