public class XJep extends JEP implements Serializable
Constructor and Description |
---|
XJep()
Create a new XJep will all the function of JEP plus printing and other features.
|
XJep(JEP j)
Conversion constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
addComplex()
Call this function if you want to parse expressions which involve
complex numbers.
|
void |
addStandardConstants()
Adds the constants pi and e to the parser.
|
void |
addStandardFunctions()
Adds the standard functions to the parser.
|
Object |
calcVarValue(String name)
Calculates the value for the variables equation and returns that value.
|
Node |
continueParsing()
Continue parsing without re-initilising the stream.
|
Node |
deepCopy(Node node)
Returns a deep copy of an expression tree.
|
Object |
evaluate(PostfixMathCommandI pfmc,
Node node) |
NodeFactory |
getNodeFactory()
Returns the node factory, used for constructing trees of Nodes.
|
PrintVisitor |
getPrintVisitor()
Returns the PrintVisitor, used for printing equations.
|
TreeUtils |
getTreeUtils()
Returns the TreeUtilitities, used for examining properties of nodes.
|
Vector |
getVarsInEquation(Node n,
Vector v)
Finds all the variables in an equation.
|
XJep |
newInstance()
Creates a new instance of XJep with the same components as this one.
|
XJep |
newInstance(SymbolTable st)
Creates a new instance of XJep with the same components as this one and the specified symbol table.
|
Node |
preprocess(Node node)
Pre-processes an equation to allow the diff and eval operators to be used.
|
void |
print(Node node)
Prints the expression tree on standard output.
|
void |
print(Node node,
PrintStream out)
Prints the expression tree on given stream.
|
void |
println(Node node)
Prints the expression tree on standard output with newline at end.
|
void |
println(Node node,
PrintStream out)
Prints the expression tree on given stream with newline at end.
|
Vector |
recursiveGetVarsInEquation(Node n,
Vector v)
Finds all the variables in an equation and if any of those
variables are defined by equations find the variables
in those equations as well.
|
void |
restartParser(Reader reader)
Restarts the parser with the given Reader.
|
void |
restartParser(String str)
Restarts the parser with the given string.
|
Node |
simplify(Node node)
Returns a simplification of an expression tree.
|
Node |
substitute(Node orig,
String[] names,
Node[] replacements)
Substitute all occurrences of a set of named variable with a set of expression tree.
|
Node |
substitute(Node orig,
String name,
Node replacement)
Substitute all occurrences of a named variable with an expression tree.
|
String |
toString(Node node)
Returns a string representation of a expression tree.
|
addConstant, addFunction, addVariable, addVariable, addVariable, evaluate, getAllowAssignment, getAllowUndeclared, getComplexValue, getErrorInfo, getEvaluatorVisitor, getFunctionTable, getImplicitMul, getNumberFactory, getOperatorSet, getParser, getSymbolTable, getTopNode, getTraverse, getValue, getValueAsObject, getVar, getVarValue, hasError, initFunTab, initSymTab, parse, parseExpression, removeFunction, removeVariable, setAllowAssignment, setAllowUndeclared, setImplicitMul, setTraverse, setVarValue
public XJep()
public XJep(JEP j)
j
- public XJep newInstance()
public XJep newInstance(SymbolTable st)
public void addStandardFunctions()
JEP
addStandardFunctions
in class JEP
public void addStandardConstants()
JEP
addStandardConstants
in class JEP
public void addComplex()
JEP
addComplex
in class JEP
public Node deepCopy(Node node) throws ParseException
ParseException
public Node simplify(Node node) throws ParseException
ParseException
public Node preprocess(Node node) throws ParseException
ParseException
public Node substitute(Node orig, String name, Node replacement) throws ParseException
ParseException
public Node substitute(Node orig, String[] names, Node[] replacements) throws ParseException
ParseException
public void print(Node node)
public void print(Node node, PrintStream out)
public void println(Node node)
public void println(Node node, PrintStream out)
public NodeFactory getNodeFactory()
public TreeUtils getTreeUtils()
public PrintVisitor getPrintVisitor()
public Object calcVarValue(String name) throws Exception
Exception
public Node continueParsing() throws ParseException
XJep j = new XJep(); j.restartParser("x=1;y=2; z=3;"); Node node; try { while((node = j.continueParsing())!=null) { j.println(node); } }catch(ParseException e) {}
ParseException
restartParser(String)
public void restartParser(String str)
str
- String containing a sequence of equations separated by semi-colons.continueParsing()
public void restartParser(Reader reader)
reader
- Reader from which equations separated by semi-colons will be read.continueParsing()
public Vector getVarsInEquation(Node n, Vector v)
n
- the top node of the expressionv
- a vector to store the list of variables (new variables will be added on end)public Vector recursiveGetVarsInEquation(Node n, Vector v) throws ParseException
For example if the equation is a+b
and
a=c+d
, b=c+e
then the
result will be the sequence (c,d,a,e,b)
n
- top nodev
- vector for storing results, new variables will be added on the end.ParseException
- if equation is recursive i.e. x=y; y=x+1;
public Object evaluate(PostfixMathCommandI pfmc, Node node) throws ParseException
ParseException
Jas4pp 1.5 © Java Analysis Studio for Particle Physics