Package com.singularsys.jep.walkers
Class GenericDoNothingVisitor<D>
java.lang.Object
com.singularsys.jep.walkers.GenericDoNothingVisitor<D>
- Type Parameters:
D- the type of the data passed to the visit methods
- All Implemented Interfaces:
GenericVisitor<Node,,D, ParseException> JepComponent,Serializable
- Direct Known Subclasses:
GenericDeepCopyVisitor,OverloadResolver,SubstitutionVisitor
public class GenericDoNothingVisitor<D>
extends Object
implements GenericVisitor<Node,D,ParseException>, JepComponent
A Visitor which visits each node, typically return the
original node. For function and operator nodes it visits
the children, if any have changed a new node is created with the new children,
otherwise the original node is returned.
This allows visitors to modify trees and create a new tree
This class should be extended by visitors which
modify trees and creates a new tree.
- Since:
- Jep 4.1
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected FunctionTableprotected NodeFactoryprotected OperatorTableI -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected booleanchildrenHaveChanged(Node node, List<Node> children) Tests if the children of a node have changedprotected NodecopyChildrenIfNeeded(ASTFunNode node, List<Node> children) Sets the children of a node if they have changed from its current children.protected NodecopyChildrenIfNeeded(ASTOpNode node, List<Node> children) Gets a light-weight instance suitable for using in multiple threads.voidInitialize the component.makeException(String message) Create an Exception of the correct type.visit(ASTConstant node, D data) Visit a constant nodevisit(ASTFunNode node, D data) Visit a function nodeVisit an operator nodevisit(ASTVarNode node, D data) Visit a variable nodeMethods 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, visit, visitChildren
-
Field Details
-
nf
-
ot
-
ft
-
-
Constructor Details
-
GenericDoNothingVisitor
public GenericDoNothingVisitor()Constructor to use as a JepComponent.init(Jep)must be called later.
-
-
Method Details
-
visit
Description copied from interface:GenericVisitorVisit a constant node- Specified by:
visitin interfaceGenericVisitor<Node,D, ParseException> - Parameters:
node- current nodedata- context data- Returns:
- the result of visiting the node
- Throws:
ParseException
-
visit
Description copied from interface:GenericVisitorVisit a function node- Specified by:
visitin interfaceGenericVisitor<Node,D, ParseException> - Parameters:
node- current nodedata- context data- Returns:
- the result of visiting the node
- Throws:
ParseException
-
visit
Description copied from interface:GenericVisitorVisit an operator node- Specified by:
visitin interfaceGenericVisitor<Node,D, ParseException> - Parameters:
node- current nodedata- context data- Returns:
- the result of visiting the node
- Throws:
ParseException
-
visit
Description copied from interface:GenericVisitorVisit a variable node- Specified by:
visitin interfaceGenericVisitor<Node,D, ParseException> - Parameters:
node- current nodedata- context data- Returns:
- the result of visiting the node
- Throws:
ParseException
-
init
Description copied from interface:JepComponentInitialize the component. This method is called whenever a component is added to Jep. Hence, it allows components to keep track of the other components they may rely on.- Specified by:
initin interfaceJepComponent- Parameters:
jep- the current Jep instance
-
getLightWeightInstance
Description copied from interface:JepComponentGets a light-weight instance suitable for using in multiple threads.- Specified by:
getLightWeightInstancein interfaceJepComponent- Returns:
- either a new instance, null or 'this'.
-
makeException
Description copied from interface:GenericVisitorCreate an Exception of the correct type. A typical implementation is@Override public JepException makeException(String message) { return new JepException(message); }- Specified by:
makeExceptionin interfaceGenericVisitor<Node,D, ParseException> - Parameters:
message- error message- Returns:
- an Exception
-
copyChildrenIfNeeded
Sets the children of a node if they have changed from its current children. If all the children are the same as the current children of the node then return the node.- Throws:
ParseException
-
copyChildrenIfNeeded
- Throws:
ParseException
-
childrenHaveChanged
Tests if the children of a node have changed- Parameters:
node- the original nodechildren- the new set of children.- Returns:
- true if any child have changed, false otherwise
-