Package com.singularsys.jep.walkers
Class ExpressionConsolidator
java.lang.Object
com.singularsys.jep.walkers.GenericDoNothingVisitor<Void>
com.singularsys.jep.walkers.GenericDeepCopyVisitor<Void>
com.singularsys.jep.walkers.ExpressionConsolidator
- All Implemented Interfaces:
GenericVisitor<Node,,Void, ParseException> JepComponent,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
FieldsFields inherited from class com.singularsys.jep.walkers.GenericDoNothingVisitor
ft, nf, ot -
Constructor Summary
ConstructorsConstructorDescriptionDefault constructor, Add and Multiply are consolidated. -
Method Summary
Modifier and TypeMethodDescriptionbooleanAdds an addition operator to be consolidated.consolidate(Node node) consolidateChildren(Operator op, List<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 nodeMethods inherited from class com.singularsys.jep.walkers.GenericDeepCopyVisitor
getLightWeightInstance, visit, visit, visit, visitMethods inherited from class com.singularsys.jep.walkers.GenericDoNothingVisitor
childrenHaveChanged, copyChildrenIfNeeded, copyChildrenIfNeeded, init, makeExceptionMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.singularsys.jep.GenericVisitor
makeException, visitChildren
-
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 interface:GenericVisitorVisit an operator node- Specified by:
visitin interfaceGenericVisitor<Node,Void, ParseException> - Overrides:
visitin classGenericDeepCopyVisitor<Void>- Parameters:
node- current nodedata- context data- Returns:
- the result of visiting the node
- Throws:
ParseException
-
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
-