All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class w3c.tools.sexpr.SimpleSExprStream

java.lang.Object
   |
   +----java.io.InputStream
           |
           +----java.io.FilterInputStream
                   |
                   +----java.io.PushbackInputStream
                           |
                           +----w3c.tools.sexpr.SimpleSExprStream

public class SimpleSExprStream
extends PushbackInputStream
implements SExprStream
Basic implementation of the SExprStream parser interface.


Constructor Index

 o SimpleSExprStream(InputStream)
Initializes the parser with no read table and no symbol table assigned.

Method Index

 o addParser(char, SExprParser)
Associates a dispatch character with a parser in the read table.
 o getListsAsVectors()
Checks whether lists should be parsed as Vectors or Cons cells.
 o getReadtable()
Accesses the read table of the parser.
 o getScratchBuffer()
Accesses an empty string buffer available temporary storage.
 o getSymbols()
Accesses the symbol table of the parser.
 o isAtomChar(char, boolean)
Predicate function for checking if a chahracter can belong to an atom.
 o main(String[])
 o makeNumber(String)
Attempts to parse a number from the string.
 o parse()
Parses a single object from the underlying input stream.
 o parse(char, SExprStream)
Parses a single object started by the character c.
 o parseAtom(char)
Parses an atom (a number or a symbol).
 o parseList()
Parses a list (as Cons cells) sans first character.
 o parseString()
Parses a double-quote -delimited string (sans the first character).
 o parseVector(Vector, char)
Parses a list (as a Vector) sans first character.
 o prettyPrint(Object)
Produces a normative form of the string representation of an s-expression.
 o printExpr(Object, PrintStream)
Produces a printed representation of an s-expression.
 o readSkipWhite()
Reads from the stream, skipping whitespace and comments.
 o setListsAsVectors(boolean)
Controls whether lists are represented as Vectors or Cons cells.
 o setReadtable(Readtable)
Assigns a new read table to the parser.
 o setSymbols(Dictionary)
Assigns a symbol table to the parser.
 o toNormativeForm(Object)
Produces a normative form of the string representation of an s-expression.
 o toString(Object)
Produces a string representation of an s-expression.

Constructors

 o SimpleSExprStream
 public SimpleSExprStream(InputStream input)
Initializes the parser with no read table and no symbol table assigned. Parsed lists will be represented as Cons cells.

Methods

 o getSymbols
 public Dictionary getSymbols()
Accesses the symbol table of the parser. If no symbol table has been assigned, creates an empty table.

 o setSymbols
 public Dictionary setSymbols(Dictionary symbols)
Assigns a symbol table to the parser. Assigning null will prevent an empty symbol table to be created in the future.

 o getReadtable
 public Readtable getReadtable()
Accesses the read table of the parser. If no read table has been assigned, creates an empty table.

 o setReadtable
 public Readtable setReadtable(Readtable readtable)
Assigns a new read table to the parser.

 o getListsAsVectors
 public boolean getListsAsVectors()
Checks whether lists should be parsed as Vectors or Cons cells.

 o setListsAsVectors
 public boolean setListsAsVectors(boolean listsAsVectors)
Controls whether lists are represented as Vectors or Cons cells.

 o getScratchBuffer
 public StringBuffer getScratchBuffer()
Accesses an empty string buffer available temporary storage. This buffer can be used by sub-parsers as a scratch area. Please note that the buffer is not guarded in any way, so multithreaded and reentrant programs must worry about this themselves.

 o parse
 public Object parse() throws SExprParserException, IOException
Parses a single object from the underlying input stream.

Throws: SExprParserException
if syntax error was detected
Throws: IOException
if any other I/O-related problem occurred
 o parse
 public Object parse(char c,
                     SExprStream stream) throws SExprParserException, IOException
Parses a single object started by the character c. Implements the SExprParser interface.

Throws: SExprParserException
if syntax error was detected
Throws: IOException
if any other I/O-related problem occurred
 o parseList
 protected Cons parseList() throws SExprParserException, IOException
Parses a list (as Cons cells) sans first character.

Throws: SExprParserException
if syntax error was detected
Throws: IOException
if any other I/O-related problem occurred
 o parseVector
 protected Vector parseVector(Vector vector,
                              char delimiter) throws SExprParserException, IOException
Parses a list (as a Vector) sans first character. In order to parse list-like structures delimited by other characters than parentheses, the delimiting (ending) character has to be provided.

Throws: SExprParserException
if syntax error was detected
Throws: IOException
if any other I/O-related problem occurred
 o parseAtom
 protected Object parseAtom(char c) throws SExprParserException, IOException
Parses an atom (a number or a symbol). Since anything that is not a number is a symbol, syntax errors are not possible.

Throws: SExprParserException
not signalled but useful for the protocol
Throws: IOException
if an I/O problem occurred (e.g. end of file)
 o parseString
 public String parseString() throws SExprParserException, IOException
Parses a double-quote -delimited string (sans the first character). Please note: no escape-character interpretation is performed. Override this method for any escape character handling.

Throws: SExprParserException
not signalled but useful for the protocol
Throws: IOException
any I/O problem (including end of file)
 o isAtomChar
 protected boolean isAtomChar(char c,
                              boolean first)
Predicate function for checking if a chahracter can belong to an atom.

Parameters:
first - if true means that c is the first character of the atom
 o readSkipWhite
 public char readSkipWhite() throws IOException
Reads from the stream, skipping whitespace and comments.

Throws: IOException
if an I/O problem occurred (including end of file)
 o makeNumber
 protected Number makeNumber(String s) throws NumberFormatException
Attempts to parse a number from the string.

Throws: NumberFormatException
the string does not represent a number
 o addParser
 public SExprParser addParser(char key,
                              SExprParser parser)
Associates a dispatch character with a parser in the read table.

 o printExpr
 public static void printExpr(Object expr,
                              PrintStream out)
Produces a printed representation of an s-expression.

 o toString
 public static String toString(Object expr)
Produces a string representation of an s-expression.

 o toNormativeForm
 public String toNormativeForm(Object v)
Produces a normative form of the string representation of an s-expression.

 o prettyPrint
 public String prettyPrint(Object v)
Produces a normative form of the string representation of an s-expression.

 o main
 public static void main(String args[]) throws SExprParserException, IOException

All Packages  Class Hierarchy  This Package  Previous  Next  Index