public class SubstitutionVisitor extends DoNothingVisitor
XJep.substitute
method.
For example
XJepI xjep = ...; Node node = xjep.parse("x^2+x"); Node sub = xjep.parse("sin(y)"); Node res = xjep.substitute(node,"x",sub,xjep);Will give the expression "(sin(y))^2+sin(y)".
Constructor and Description |
---|
SubstitutionVisitor() |
Modifier and Type | Method and Description |
---|---|
Node |
substitute(Node orig,
java.lang.String[] names,
Node[] replacements,
XJep xj)
Substitutes all occurrences of a set of variable var with a set of replacements.
|
Node |
substitute(Node orig,
java.lang.String name,
Node replacement,
XJep xj)
Substitutes all occurrences of variable var with replacement.
|
java.lang.Object |
visit(ASTVarNode node,
java.lang.Object data) |
acceptChildrenAsArray, visit, visit, visit, visit
public Node substitute(Node orig, java.lang.String name, Node replacement, XJep xj) throws ParseException
orig
- the expression we wish to perform the substitution onname
- the name of the variablereplacement
- the expression var is substituted forParseException
public Node substitute(Node orig, java.lang.String[] names, Node[] replacements, XJep xj) throws ParseException
orig
- the expression we wish to perform the substitution onnames
- the names of the variablereplacements
- the expression var is substituted forParseException
public java.lang.Object visit(ASTVarNode node, java.lang.Object data) throws ParseException
visit
in interface ParserVisitor
visit
in class DoNothingVisitor
ParseException
http://www.singularsys.com/jep Copyright © 2007 Singular Systems