com.singularsys.jep.walkers
Class TreeAnalyzer
java.lang.Object
com.singularsys.jep.walkers.PostfixTreeWalker
com.singularsys.jep.walkers.TreeAnalyzer
public class TreeAnalyzer
- extends PostfixTreeWalker
Analyze an expression, counting the number of nodes of each type, and recording which variables,
functions and operators occurred in the expression.
Method Summary |
java.util.Map<java.lang.String,java.lang.Integer> |
getFunctions()
A map with each function used and the number of times it occurred |
int |
getMaxDepth()
|
int |
getNumConst()
|
int |
getNumFunctions()
|
int |
getNumNodes()
|
int |
getNumOperators()
|
int |
getNumVariables()
|
java.util.Map<Operator,java.lang.Integer> |
getOperators()
A map with each operator used and the number of times it occurred |
java.util.Map<Variable,java.lang.Integer> |
getVariables()
A map with each variable used and the number of times it occurred |
java.lang.String |
toString()
|
protected void |
visit(ASTConstant node,
int nchildren,
int depth)
|
protected void |
visit(ASTFunNode node,
int nchildren,
int depth)
|
protected void |
visit(ASTOpNode node,
int nchildren,
int depth)
|
protected void |
visit(ASTVarNode node,
int nchildren,
int depth)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
TreeAnalyzer
public TreeAnalyzer(Node node)
throws JepException
- Throws:
JepException
toString
public java.lang.String toString()
- Overrides:
toString
in class java.lang.Object
visit
protected void visit(ASTFunNode node,
int nchildren,
int depth)
- Specified by:
visit
in class PostfixTreeWalker
visit
protected void visit(ASTOpNode node,
int nchildren,
int depth)
- Specified by:
visit
in class PostfixTreeWalker
visit
protected void visit(ASTVarNode node,
int nchildren,
int depth)
- Specified by:
visit
in class PostfixTreeWalker
visit
protected void visit(ASTConstant node,
int nchildren,
int depth)
- Specified by:
visit
in class PostfixTreeWalker
getMaxDepth
public int getMaxDepth()
getNumConst
public int getNumConst()
getNumFunctions
public int getNumFunctions()
getNumNodes
public int getNumNodes()
getNumOperators
public int getNumOperators()
getNumVariables
public int getNumVariables()
getOperators
public java.util.Map<Operator,java.lang.Integer> getOperators()
- A map with each operator used and the number of times it occurred
getVariables
public java.util.Map<Variable,java.lang.Integer> getVariables()
- A map with each variable used and the number of times it occurred
getFunctions
public java.util.Map<java.lang.String,java.lang.Integer> getFunctions()
- A map with each function used and the number of times it occurred
Copyright © 2007 Singular Systems http://www.singularsys.com/jep