slogo.jelan.parser
Class ElanInterpreter

java.lang.Object
  extended by slogo.jelan.parser.ElanInterpreter

public class ElanInterpreter
extends java.lang.Object

Illustrates the java.io.StreamTokenizer class and how it can be used to parse tokens for an example programming language (elan). For this example simple instructions are parsed, but lots of infrastructure is in place for parsing a more complete language.

Author:
Owen Astrachan
See Also:
slogo.jelan.expressions, slogo.jelan.instructions, InstructionParser

Constructor Summary
ElanInterpreter()
           
 
Method Summary
 void error(Token t)
           
 Token getToken()
          returns the current token, doesn't fetch a new one
 void interpreter(java.io.Reader r)
          parses an expression and prints the result of evaluating the expression.
static void main(java.lang.String[] args)
          Basic driver for ElanParser
 Token match(Token rhs)
          try to match a token, if unsuccessful throw an exception, otherwise match succeeds, and next token is obtained and returned
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ElanInterpreter

public ElanInterpreter()
Method Detail

interpreter

public void interpreter(java.io.Reader r)
parses an expression and prints the result of evaluating the expression.

Parameters:
r - the reader that will be tokenized

getToken

public Token getToken()
returns the current token, doesn't fetch a new one

Returns:
the current token

match

public Token match(Token rhs)
try to match a token, if unsuccessful throw an exception, otherwise match succeeds, and next token is obtained and returned

Parameters:
rhs - token being matched
Returns:
the next read token
Throws:
ParseException - if match fails

error

public void error(Token t)
Parameters:
t - token where error occurred
Throws:
a - ParseException labeled by t

main

public static void main(java.lang.String[] args)
Basic driver for ElanParser

Parameters:
args -