Package com.singularsys.jep.walkers
Class ExpressionConsolidator
java.lang.Object
com.singularsys.jep.walkers.DoNothingVisitor
com.singularsys.jep.walkers.DeepCopyVisitor
com.singularsys.jep.walkers.ExpressionConsolidator
- All Implemented Interfaces:
JepComponent
,ParserVisitor
,Serializable
Consolidates nested addition and multiplication to produce nary operators.
For example (x+y)+z -> +(x,y,z)
- Author:
- Richard Morris
- See Also:
-
Field Summary
-
Constructor Summary
ConstructorDescriptionDefault constructor, Add and Multiply are consolidated. -
Method Summary
Modifier and TypeMethodDescriptionboolean
Adds an addition operator to be consolidated.consolidate
(Node node) protected Node[]
consolidateChildren
(Operator op, Node[] children) Creates an array of Nodes, if the child is an ASTOpNode whose operator is op, then the children of that child will be added otherwise the child is added.getOps()
The list of operators which are consolidatedVisit an operator node.Methods inherited from class com.singularsys.jep.walkers.DeepCopyVisitor
deepCopy, visit, visit, visit
Methods inherited from class com.singularsys.jep.walkers.DoNothingVisitor
childrenHaveChanged, copyChildrenIfNeeded, getFunctionTable, getLightWeightInstance, getNodeFactory, getOperatorTable, getVariableTable, init, visit, visitChildren, visitNode
-
Field Details
-
ops
-
-
Constructor Details
-
ExpressionConsolidator
Default constructor, Add and Multiply are consolidated.- Parameters:
j
-
-
-
Method Details
-
consolidate
- Throws:
JepException
-
consolidateChildren
Creates an array of Nodes, if the child is an ASTOpNode whose operator is op, then the children of that child will be added otherwise the child is added.- Parameters:
op
-children
-- Returns:
- a new list of nodes
-
visit
Description copied from class:DoNothingVisitor
Visit an operator node. Can be overridden by subclasses.- Specified by:
visit
in interfaceParserVisitor
- Overrides:
visit
in classDeepCopyVisitor
- Throws:
JepException
-
add
Adds an addition operator to be consolidated.- Parameters:
op
- operator to use- Returns:
- true
-
getOps
The list of operators which are consolidated- Returns:
- the list
-