edu.rice.cs.util.sexp
Class SExpParser.ParseHelper

java.lang.Object
  extended by edu.rice.cs.util.sexp.SExpParser.ParseHelper
Enclosing class:
SExpParser

private static class SExpParser.ParseHelper
extends Object

A new helper is instantiated for each time the user wants to parse data. This is not reused. The instances of the ParseHelpers are handled solely in the outer class SExpParser.


Field Summary
private  Lexer _lex
           
 
Constructor Summary
SExpParser.ParseHelper(Reader r)
           
 
Method Summary
private  void assertNotEOF(Tokens.SExpToken t)
          Throws the EOF exception if the given token is the end of file
private  Atom parseAtom(Tokens.SExpToken t)
          Parses an atom.
 SExp parseExp()
          Parses the next s-expression in the lexer's buffer.
private  SEList parseList()
          The left paren has already been read.
 List<SEList> parseMultiple()
          Parse a forest of top-level s-expressions from parseTopLevelExp().
 SEList parseTopLevelExp()
          A top-level s-expression is simply a non-empty list.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_lex

private Lexer _lex
Constructor Detail

SExpParser.ParseHelper

public SExpParser.ParseHelper(Reader r)
Method Detail

parseMultiple

public List<SEList> parseMultiple()
Parse a forest of top-level s-expressions from parseTopLevelExp().

See Also:
parseTopLevelExp()

parseTopLevelExp

public SEList parseTopLevelExp()
A top-level s-expression is simply a non-empty list. Our s-expression files can be a forest of several trees, but the Atomic values are not allowed at the top level, only lists.

Returns:
the top-level list s-expression

parseExp

public SExp parseExp()
Parses the next s-expression in the lexer's buffer. This may be either a cons or an atom

Returns:
the next s-expression in the read buffer.

parseList

private SEList parseList()
The left paren has already been read. This starts building up the recursive list structure

Returns:
the parsed recursive s-expression list

parseAtom

private Atom parseAtom(Tokens.SExpToken t)
Parses an atom. The token was already read and found not to start a list, this method interprets what is given. This method chooses which type of atom the token represents and creates the atom.

Parameters:
t - the token to interpret
Returns:
the correct corresponding atom

assertNotEOF

private void assertNotEOF(Tokens.SExpToken t)
Throws the EOF exception if the given token is the end of file

Parameters:
t - the token to check