public class SLogoInterpreter
extends java.lang.Object
slogo.expression
,
slogo.instruction
,
InstructionParser
Modifier and Type | Field and Description |
---|---|
private Token |
myToken |
private java.io.StreamTokenizer |
myTokenizer |
private java.io.PrintStream |
outAndErrStream |
private TurtleField |
turtleField |
Constructor and Description |
---|
SLogoInterpreter(java.io.PrintStream outAndErrStream,
TurtleField turtleField)
SlogoInterpreter Constructor
|
Modifier and Type | Method and Description |
---|---|
void |
error(Token t) |
Token |
getToken()
returns the current token, doesn't fetch a new one
|
TurtleField |
getTurtleField()
Gets the turtleField so that other tokens can use it
|
void |
initializeTokenizer(java.io.Reader reader) |
void |
interpret(java.io.Reader reader)
interprets the contents of the Reader: parsing
expression(s) and prints the result of evaluating the expression(s).
|
void |
interpret(java.io.Reader reader,
SLogoTurtle c) |
void |
interpret(java.io.Reader reader,
SLogoTurtle c,
boolean printLine) |
Token |
match(Token rhs)
try to match a token, if unsuccessful throw an exception, otherwise match
succeeds, and next token is obtained and returned
|
Token |
nextToken()
get the next token and store it for retrieval by getToken()
|
private java.io.StreamTokenizer myTokenizer
private Token myToken
private java.io.PrintStream outAndErrStream
private TurtleField turtleField
public SLogoInterpreter(java.io.PrintStream outAndErrStream, TurtleField turtleField)
public void initializeTokenizer(java.io.Reader reader)
reader
- is the reader that reads the commandspublic void interpret(java.io.Reader reader)
reader
- the reader that will be tokenizedpublic void interpret(java.io.Reader reader, SLogoTurtle c, boolean printLine)
reader
- is the Reader that reads the commandsc
- is the SlogoTurtle that evaluates the evaluates the commandspublic void interpret(java.io.Reader reader, SLogoTurtle c)
reader
- is the Reader that reads the commandsc
- is the SlogoTurtle that evaluates the evaluates the commandspublic Token nextToken()
public Token getToken()
public Token match(Token rhs)
rhs
- token being matchedParseException
- if match failspublic void error(Token t)
t
- token where error occurreda
- ParseException labeled by tpublic TurtleField getTurtleField()