Factory for creating an ExpressionNode representing '-'.
More...
|
| numericTerms ($leftOperand, $rightOperand) |
| Simplify subtraction nodes for numeric operands. More...
|
|
Factory for creating an ExpressionNode representing '-'.
Some basic simplification is applied to the resulting Node.
MathParser\Parsing\Nodes\Factories\SubtractionNodeFactory::createUnaryMinusNode |
( |
|
$operand | ) |
|
Create a Node representing '-$operand'.
Using some simplification rules, create a NumberNode or ExpressionNode giving an AST correctly representing '-$operand'.
Simplification rules:
- To simplify the use of the function, convert integer params to NumberNodes
- If $operand is a NumberNodes, return a single NumberNode containing its negative
- If $operand already is a unary minus, 'x=-y', return y
- Parameters
-
Node | int | $operand | Operand |
- Return values
-
MathParser\Parsing\Nodes\Factories\SubtractionNodeFactory::makeNode |
( |
|
$leftOperand, |
|
|
|
$rightOperand |
|
) |
| |
Create a Node representing 'leftOperand - rightOperand'.
Using some simplification rules, create a NumberNode or ExpressionNode giving an AST correctly representing 'rightOperand - leftOperand'.
Simplification rules:
- To simplify the use of the function, convert integer params to NumberNodes
- If $rightOperand is null, return a unary minus node '-x' instead
- If $leftOperand and $rightOperand are both NumberNodes, return a single NumberNode containing their difference
- If $rightOperand is a NumberNode representing 0, return $leftOperand unchanged
- If $leftOperand and $rightOperand are equal, return '0'
- Parameters
-
Node | int | float | $leftOperand | Minuend |
Node | int | float | $rightOperand | Subtrahend |
- Return values
-
Implements MathParser\Parsing\Nodes\Interfaces\ExpressionNodeFactory.
MathParser\Parsing\Nodes\Factories\SubtractionNodeFactory::numericTerms |
( |
|
$leftOperand, |
|
|
|
$rightOperand |
|
) |
| |
|
protected |
Simplify subtraction nodes for numeric operands.
- Parameters
-
- Return values
-
The documentation for this class was generated from the following file:
- src/MathParser/Parsing/Nodes/Factories/SubtractionNodeFactory.php