|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.nfunk.jep.JEP
org.lsmp.djep.xjep.XJep
An extended version of JEP adds various routines for working with trees. Has a NodeFactory, and OperatorSet, TreeUtils and Visitors DoNothingVisitor,
Field Summary | |
protected CommandVisitor |
commandv
|
protected DeepCopyVisitor |
copier
|
protected NodeFactory |
nf
Creates new nodes |
protected PrintVisitor |
pv
|
protected SimplificationVisitor |
simpv
|
protected SubstitutionVisitor |
subv
|
protected TreeUtils |
tu
A few utility functions. |
Fields inherited from class org.nfunk.jep.JEP |
allowAssignment, allowUndeclared, errorList, ev, funTab, implicitMul, numberFactory, opSet, parser, symTab |
Constructor Summary | |
|
XJep()
Create a new XJep will all the function of JEP plus printing and other features. |
|
XJep(JEP j)
Conversion constructor. |
protected |
XJep(XJep j)
Copy constructions, reuses all the componants of argument. |
Method Summary | |
void |
addStandardConstants()
Adds the constants pi and e to the parser. |
void |
addStandardFunctions()
Adds the standard functions to the parser. |
java.lang.Object |
calcVarValue(java.lang.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. |
java.lang.Object |
evaluate(Node node)
Evaluates a 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. |
XJep |
newInstance()
Creates a new instance of XJep with the same componants as this one. |
XJep |
newInstance(SymbolTable st)
Creates a new instance of XJep with the same componants as this one and the specified symbol table. |
Node |
preprocess(Node node)
Preprocesses an equation to allow the diff and eval operators to be used. |
void |
print(Node node)
Prints the expresion tree on standard output. |
void |
print(Node node,
java.io.PrintStream out)
Prints the expresion tree on given stream. |
void |
println(Node node)
Prints the expresion tree on standard output with newline at end. |
void |
println(Node node,
java.io.PrintStream out)
Prints the expresion tree on given stream with newline at end. |
void |
restartParser(java.io.Reader reader)
Restarts the parser with the given Reader. |
void |
restartParser(java.lang.String str)
Restarts the parser with the given string. |
Node |
simplify(Node node)
Returns a simplification of an expression tree. |
Node |
substitute(Node orig,
java.lang.String[] names,
Node[] replacements)
Substitute all occurences of a set of named variable with a set of expression tree. |
Node |
substitute(Node orig,
java.lang.String name,
Node replacement)
Substitute all occurences of a named variable with an expression tree. |
java.lang.String |
toString(Node node)
Returns a string representation of a expresion tree. |
Methods inherited from class org.nfunk.jep.JEP |
addComplex, addConstant, addFunction, addVariable, addVariable, addVariable, getAllowAssignment, getAllowUndeclared, getComplexValue, getErrorInfo, getFunctionTable, getImplicitMul, getNumberFactory, getOperatorSet, getParser, getSymbolTable, getTopNode, getTraverse, getValue, getValueAsObject, getVar, getVarValue, hasError, initFunTab, initSymTab, parse, parseExpression, removeFunction, removeVariable, setAllowAssignment, setAllowUndeclared, setImplicitMul, setTraverse, setVarValue |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected NodeFactory nf
protected TreeUtils tu
protected DeepCopyVisitor copier
protected SubstitutionVisitor subv
protected SimplificationVisitor simpv
protected CommandVisitor commandv
protected PrintVisitor pv
Constructor Detail |
public XJep()
protected XJep(XJep j)
public XJep(JEP j)
j
- Method Detail |
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 Node deepCopy(Node node) throws ParseException
ParseException
public java.lang.Object evaluate(Node node) throws java.lang.Exception
evaluate
in class JEP
node
- the top node of the tree representing the expression.
java.lang.Exception
- if for some reason the expression could not be evaluatedpublic Node simplify(Node node) throws ParseException
ParseException
public Node preprocess(Node node) throws ParseException
ParseException
public Node substitute(Node orig, java.lang.String name, Node replacement) throws ParseException
ParseException
public Node substitute(Node orig, java.lang.String[] names, Node[] replacements) throws ParseException
ParseException
public void print(Node node)
public void print(Node node, java.io.PrintStream out)
public void println(Node node)
public void println(Node node, java.io.PrintStream out)
public java.lang.String toString(Node node)
public NodeFactory getNodeFactory()
public TreeUtils getTreeUtils()
public PrintVisitor getPrintVisitor()
public java.lang.Object calcVarValue(java.lang.String name) throws java.lang.Exception
java.lang.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(java.lang.String)
public void restartParser(java.lang.String str)
str
- String containing a sequence of equations separated by semi-colons.continueParsing()
public void restartParser(java.io.Reader reader)
reader
- Reader from which equations separated by semi-colons will be read.continueParsing()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |