Class LoopNode
- java.lang.Object
-
- com.singularsys.jep.parser.SimpleNode
-
- com.singularsys.extensions.structure.StructureNode
-
- com.singularsys.extensions.structure.LoopNode
-
- All Implemented Interfaces:
Node
public class LoopNode extends StructureNode
A node represents a looping construct such as afor
orwhile
loop.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
LoopNode.ControlValues
Special values to indicate break and continue statements Used byControlRule
andControlNode
.-
Nested classes/interfaces inherited from interface com.singularsys.jep.parser.Node
Node.HookKey
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Object
eval(Evaluator ev)
Evaluate the Loop.Node
getBody()
Node
getCondition()
Node
getIncrement()
Node
getInitilise()
java.lang.String
toString()
-
Methods inherited from class com.singularsys.extensions.structure.StructureNode
getName, getOperator, getPFMC, getValue, getVar, testCondition
-
Methods inherited from class com.singularsys.jep.parser.SimpleNode
childIterator, children, childrenAccept, dump, getHook, getId, hookKeys, jjtAccept, jjtAddChild, jjtClose, jjtGetChild, jjtGetNumChildren, jjtGetParent, jjtOpen, jjtSetParent, removeHook, setHook, toString
-
-
-
-
Constructor Detail
-
LoopNode
public LoopNode(Node initilise, Node condition, Node increment, Node body)
Constructor.- Parameters:
initilise
- node evaluate at start of loop, can be nullcondition
- evaluated and tested before each evaluation, can be nullincrement
- evaluated after each iteration, can be nullbody
- evaluated once per iteration
-
-
Method Detail
-
getInitilise
public Node getInitilise()
-
getCondition
public Node getCondition()
-
getIncrement
public Node getIncrement()
-
getBody
public Node getBody()
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
eval
public java.lang.Object eval(Evaluator ev) throws EvaluationException
Evaluate the Loop.- First evaluate the initialisation (if given)
- Evaluate the condition (if given), if result is false exit
- Evaluate the body, if the result is break exit
- Evaluate the increment (if given)
- loop to 2
- Specified by:
eval
in classStructureNode
- Parameters:
ev
- The evaluator theEvaluator.eval(com.singularsys.jep.parser.Node)
can be used to evaluate children.- Returns:
- result of evaluation
- Throws:
EvaluationException
- if evaluation cannot be performed
-
-