Abstract base class for nodes in the abstract syntax tree generated by the Parser (and some AST transformers).
More...
|
const | NumericInteger = 1 |
|
const | NumericRational = 2 |
|
const | NumericFloat = 3 |
|
Abstract base class for nodes in the abstract syntax tree generated by the Parser (and some AST transformers).
MathParser\Parsing\Nodes\Node::compareTo |
( |
|
$other | ) |
|
|
abstract |
Helper function, comparing two ASTs.
Useful for testing and also for some AST transformers.
- Parameters
-
Node | null | $other | Compare to this tree |
- Return values
-
MathParser\Parsing\Nodes\Node::complexity |
( |
| ) |
|
Rough estimate of the complexity of the AST.
Gives a rough measure of the complexity of an AST. This can be useful to choose between different simplification rules or how to print a tree ("e^{...}" or ("\exp(...)") for example.
More precisely, the complexity is computed as the sum of the complexity of all nodes of the AST, and
- NumberNodes, VariableNodes and ConstantNodes have complexity 1,
- FunctionNodes have complexity 5 (plus the complexity of its operand),
- ExpressionNodes have complexity 2 (for
+
, -
, *
), 4 (for /
), or 8 (for ^
)
MathParser\Parsing\Nodes\Node::evaluate |
( |
|
$variables | ) |
|
Convenience function for evaluating a tree, using the Evaluator class.
Example usage:
$parser = new StdMathParser();
$node = $parser->parse('sin(x)cos(y)');
$functionValue = $node->evaluate( array( 'x' => 1.3, 'y' => 1.4 ) );
- Parameters
-
array | $variables | key-value array of variable values |
- Return values
-
static MathParser\Parsing\Nodes\Node::factory |
( |
Token |
$token | ) |
|
|
static |
Node factory, creating an appropriate Node from a Token.
Based on the provided Token, returns a TerminalNode if the token type is PosInt, Integer, RealNumber, Identifier or Constant otherwise returns null.
- Parameters
-
Token | $token | Provided token |
- Return values
-
MathParser\Parsing\Nodes\Node::isTerminal |
( |
| ) |
|
static MathParser\Parsing\Nodes\Node::rationalFactory |
( |
Token |
$token | ) |
|
|
static |
Node factory, creating an appropriate Node from a Token.
Based on the provided Token, returns a TerminalNode if the token type is PosInt, Integer, RealNumber, Identifier or Constant otherwise returns null.
- Parameters
-
Token | $token | Provided token |
- Return values
-
The documentation for this class was generated from the following file:
- src/MathParser/Parsing/Nodes/Node.php