net.scheinerman.phoenix.interpreter
Class WhileInterpreter

java.lang.Object
  extended by net.scheinerman.phoenix.interpreter.Interpreter
      extended by net.scheinerman.phoenix.interpreter.LoopInterpreter
          extended by net.scheinerman.phoenix.interpreter.WhileInterpreter
Direct Known Subclasses:
DoWhileInterpreter

public class WhileInterpreter
extends LoopInterpreter

Extends the LoopInterpreter to provide while looping functionality. The while loop provides support for a loop that continues until a given ending condition (the while statement) evaluates to false (zero).

Since:
1.5
Version:
1.0
Author:
Jonah Scheinerman

Field Summary
protected  java.lang.String whileStatement
           
 
Fields inherited from class net.scheinerman.phoenix.interpreter.Interpreter
_break, _continue, _return, breakValue, code, fat, file, keywordList, line, line_diff, printValues, retType, retTypeSet, retValue, run_code, stop, vat
 
Constructor Summary
WhileInterpreter(java.lang.String file, java.lang.String code, int line, java.lang.String whileStatement, java.util.LinkedList<java.util.HashMap<java.lang.String,Variable>> vat, java.util.LinkedList<java.util.HashMap<java.lang.String,Function>> fat)
          Creates a new while loop interpreter.
 
Method Summary
protected  boolean isDone()
          Returns true if the end statement evaluates to zero, false if the end statement evaluates to a true (non-zero) value.
 
Methods inherited from class net.scheinerman.phoenix.interpreter.LoopInterpreter
afterEnd, beforeStart, dealWithBreak, dealWithContinue, run
 
Methods inherited from class net.scheinerman.phoenix.interpreter.Interpreter
dealWithError, dealWithReturn, delete, doRun, getBlock, getFunction, getFunctionArguments, getFunctionFromDefinition, getReturnValue, getVariable, getWhitespace, initNewTables, isValidIdentifier, makeDefaultVariable, makeFunction, makeVariable, makeVariable, parsePhrase, putFunction, removeComments, removeWhitespace, retValueMatches
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

whileStatement

protected java.lang.String whileStatement
Constructor Detail

WhileInterpreter

public WhileInterpreter(java.lang.String file,
                        java.lang.String code,
                        int line,
                        java.lang.String whileStatement,
                        java.util.LinkedList<java.util.HashMap<java.lang.String,Variable>> vat,
                        java.util.LinkedList<java.util.HashMap<java.lang.String,Function>> fat)
Creates a new while loop interpreter. This constructor provides the necessary requirements for any interpreter subclass. The VAT and FAT of the enclosing interpreter, the file, the code section, the line number, and the ending condition of the while loop. Any subclasses must use these constructor arguments along with any others that they might need for that specific implementation.

Parameters:
file - - The currently read file.
code - - The lines of code that are to be executed.
line - - The starting line number.
whileStatement - - The code phrase which provides the ending condition of the loop.
vat - - The enclosing interpreter's VAT.
fat - - The enclosing interpreter's FAT.
Method Detail

isDone

protected boolean isDone()
Returns true if the end statement evaluates to zero, false if the end statement evaluates to a true (non-zero) value. This determines whether the loop has ended.

Overrides:
isDone in class LoopInterpreter
Returns:
true if the loop should end, false if not.