MathParser\Parsing\Nodes\Factories\NodeFactory Class Reference

Helper class for creating ExpressionNodes. More...

Public Member Functions

 __construct ()
 Constructor.
 
 addition ($leftOperand, $rightOperand)
 Create an addition node representing '$leftOperand + $rightOperand'. More...
 
 subtraction ($leftOperand, $rightOperand)
 Create a subtraction node representing '$leftOperand - $rightOperand'. More...
 
 multiplication ($leftOperand, $rightOperand)
 Create a multiplication node representing '$leftOperand * $rightOperand'. More...
 
 division ($leftOperand, $rightOperand)
 Create a division node representing '$leftOperand / $rightOperand'. More...
 
 exponentiation ($leftOperand, $rightOperand)
 Create an exponentiation node representing '$leftOperand ^ $rightOperand'. More...
 
 unaryMinus ($operand)
 Create a unary minus node representing '-$operand'. More...
 
 simplify (ExpressionNode $node)
 Simplify the given ExpressionNode, using the appropriate factory. More...
 

Protected Attributes

 $additionFactory
 Factory for creating addition nodes.
 
 $subtractionFactory
 Factory for creating subtraction nodes (including unary minus)
 
 $multiplicationFactory
 Factory for creating multiplication nodes.
 
 $divisionFactory
 Factory for creating division nodes.
 
 $exponentiationFactory
 Factory for creating exponentiation nodes.
 

Detailed Description

Helper class for creating ExpressionNodes.

Wrapper class, setting up factories for creating ExpressionNodes of various types (one for each operator). These factories take case of basic simplification.

Examples

$factory = new NodeFactory();
// Create AST for 'x/y + x*y'
$node = $factory->addition(
$factory->division(new VariableNode('x'), new VariableNode('y')),
$factory->multiplication(new VariableNode('x'), new VariableNode('y'))
);

Member Function Documentation

MathParser\Parsing\Nodes\Factories\NodeFactory::addition (   $leftOperand,
  $rightOperand 
)

Create an addition node representing '$leftOperand + $rightOperand'.

Parameters
mixed$leftOperand
mixed$rightOperand
Return values
ExpressionNode
MathParser\Parsing\Nodes\Factories\NodeFactory::division (   $leftOperand,
  $rightOperand 
)

Create a division node representing '$leftOperand / $rightOperand'.

Parameters
mixed$leftOperand
mixed$rightOperand
Return values
ExpressionNode
MathParser\Parsing\Nodes\Factories\NodeFactory::exponentiation (   $leftOperand,
  $rightOperand 
)

Create an exponentiation node representing '$leftOperand ^ $rightOperand'.

Parameters
mixed$leftOperand
mixed$rightOperand
Return values
ExpressionNode
MathParser\Parsing\Nodes\Factories\NodeFactory::multiplication (   $leftOperand,
  $rightOperand 
)

Create a multiplication node representing '$leftOperand * $rightOperand'.

Parameters
mixed$leftOperand
mixed$rightOperand
Return values
ExpressionNode
MathParser\Parsing\Nodes\Factories\NodeFactory::simplify ( ExpressionNode  $node)

Simplify the given ExpressionNode, using the appropriate factory.

Parameters
ExpressionNode$node
Return values
NodeSimplified version of the input
MathParser\Parsing\Nodes\Factories\NodeFactory::subtraction (   $leftOperand,
  $rightOperand 
)

Create a subtraction node representing '$leftOperand - $rightOperand'.

Parameters
mixed$leftOperand
mixed$rightOperand
Return values
ExpressionNode
MathParser\Parsing\Nodes\Factories\NodeFactory::unaryMinus (   $operand)

Create a unary minus node representing '-$operand'.

Parameters
mixed$operand
Return values
ExpressionNode

The documentation for this class was generated from the following file: