elan.parser
Class ElanParser

java.lang.Object
  |
  +--elan.parser.ElanParser

public class ElanParser
extends java.lang.Object

A singleton; uses the StreamTokenizer class to parse an input file based on set options.

See Also:
elan.expression, elan.instruction

Field Summary
protected  Token myToken
           
protected  java.io.StreamTokenizer myTokenizer
           
 
Constructor Summary
ElanParser()
           
 
Method Summary
 void error(Token t)
           
 int getCurrentLineNumber()
          Returns the current line number where the parser is.
static ElanParser getInstance()
          returns the ElanParser instance.
 java.util.ArrayList getInstructions()
          Returns the instructions that are stored while parsing.
 Token getToken()
           
 void incrementLineNumber()
          Increments the internal line number counter.
 Token match(Token rhs)
          try to match a token, if unsuccessful throw an exception, otherwise match succeeds, and next token is obtained and returned
protected  Token nextToken()
          get the next token and store it for retrieval by getToken()
 boolean parse(java.io.Reader r)
          parses an expression and prints the result of evaluating the expression.
protected  void skipLines()
          skip EOL tokens, the next call of getToken() returns something other than EOLToken
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

myTokenizer

protected java.io.StreamTokenizer myTokenizer

myToken

protected Token myToken
Constructor Detail

ElanParser

public ElanParser()
Method Detail

getInstance

public static ElanParser getInstance()
returns the ElanParser instance.


parse

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

Parameters:
r - is the reader that will be tokenized

skipLines

protected void skipLines()
skip EOL tokens, the next call of getToken() returns something other than EOLToken


nextToken

protected Token nextToken()
get the next token and store it for retrieval by getToken()

Returns:
the current (just read) token
See Also:
getToken

getToken

public Token getToken()
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 - is the token being matched
Returns:
the next read token
Throws:
ParseException - (RunTime) if match fails

error

public void error(Token t)
Parameters:
t - is included in expeption thrown
Throws:
a - ParseException labelled by t

getInstructions

public java.util.ArrayList getInstructions()
Returns the instructions that are stored while parsing.


getCurrentLineNumber

public int getCurrentLineNumber()
Returns the current line number where the parser is.


incrementLineNumber

public void incrementLineNumber()
Increments the internal line number counter.