Package com.singularsys.extensions.xjep
Class CommandVisitor
java.lang.Object
com.singularsys.jep.walkers.GenericDoNothingVisitor<Void>
com.singularsys.jep.walkers.GenericDeepCopyVisitor<Void>
com.singularsys.extensions.xjep.CommandVisitor
- All Implemented Interfaces:
GenericVisitor<Node,,Void, ParseException> JepComponent,Serializable
Executes commands like diff and eval embedded in expression trees. For
example, you could do
eval(diff(x ^ 3, x), x, 2)to differentiate x^3 and then substitute x=2 to get the value 12. To use do
Jep j = ...; Node in = ...; TreeUtils tu = new TreeUtils(j); CommandVisitor cv = new CommandVisitor(tu); Node out = cv.process(in);Commands to be executed must implement
CommandVisitorI and PostfixMathCommandI. See ParserVisitor for details on the VisitorPattern.- Author:
- R Morris Created on 19-Jun-2003
- See Also:
-
Field Summary
Fields inherited from class com.singularsys.jep.walkers.GenericDoNothingVisitor
ft, nf, ot -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionDescends the tree processing all diff, eval and simplify optionsvisit(ASTConstant node, Void data) Visit a constant nodevisit(ASTFunNode node, Void data) Visit a function nodeVisit an operator nodevisit(ASTVarNode node, Void data) Visit a variable nodeMethods inherited from class com.singularsys.jep.walkers.GenericDeepCopyVisitor
getLightWeightInstance, 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
-
Constructor Details
-
CommandVisitor
public CommandVisitor()
-
-
Method Details
-
process
Descends the tree processing all diff, eval and simplify options- Throws:
ParseException
-
visit
Description copied from interface:GenericVisitorVisit a function 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
-
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
-
visit
Description copied from interface:GenericVisitorVisit a constant 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
-
visit
Description copied from interface:GenericVisitorVisit a variable 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
-