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.
-
SimpleSExprStream(InputStream)
- Initializes the parser with no read table and no symbol table assigned.
-
addParser(char, SExprParser)
- Associates a dispatch character with a parser in the read table.
-
getListsAsVectors()
- Checks whether lists should be parsed as Vectors or Cons cells.
-
getReadtable()
- Accesses the read table of the parser.
-
getScratchBuffer()
- Accesses an empty string buffer available temporary storage.
-
getSymbols()
- Accesses the symbol table of the parser.
-
isAtomChar(char, boolean)
- Predicate function for checking if a chahracter can belong to an atom.
-
main(String[])
-
-
makeNumber(String)
- Attempts to parse a number from the string.
-
parse()
- Parses a single object from the underlying input stream.
-
parse(char, SExprStream)
- Parses a single object started by the character c.
-
parseAtom(char)
- Parses an atom (a number or a symbol).
-
parseList()
- Parses a list (as Cons cells) sans first character.
-
parseString()
- Parses a double-quote -delimited string (sans the first character).
-
parseVector(Vector, char)
- Parses a list (as a Vector) sans first character.
-
prettyPrint(Object)
- Produces a normative form of the string representation of
an s-expression.
-
printExpr(Object, PrintStream)
- Produces a printed representation of an s-expression.
-
readSkipWhite()
- Reads from the stream, skipping whitespace and comments.
-
setListsAsVectors(boolean)
- Controls whether lists are represented as Vectors or Cons cells.
-
setReadtable(Readtable)
- Assigns a new read table to the parser.
-
setSymbols(Dictionary)
- Assigns a symbol table to the parser.
-
toNormativeForm(Object)
- Produces a normative form of the string representation of
an s-expression.
-
toString(Object)
- Produces a string representation of an s-expression.
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.
getSymbols
public Dictionary getSymbols()
- Accesses the symbol table of the parser.
If no symbol table has been assigned, creates an empty table.
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.
getReadtable
public Readtable getReadtable()
- Accesses the read table of the parser.
If no read table has been assigned, creates an empty table.
setReadtable
public Readtable setReadtable(Readtable readtable)
- Assigns a new read table to the parser.
getListsAsVectors
public boolean getListsAsVectors()
- Checks whether lists should be parsed as Vectors or Cons cells.
setListsAsVectors
public boolean setListsAsVectors(boolean listsAsVectors)
- Controls whether lists are represented as Vectors or Cons cells.
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.
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
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
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
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
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)
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)
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
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)
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
addParser
public SExprParser addParser(char key,
SExprParser parser)
- Associates a dispatch character with a parser in the read table.
printExpr
public static void printExpr(Object expr,
PrintStream out)
- Produces a printed representation of an s-expression.
toString
public static String toString(Object expr)
- Produces a string representation of an s-expression.
toNormativeForm
public String toNormativeForm(Object v)
- Produces a normative form of the string representation of
an s-expression.
prettyPrint
public String prettyPrint(Object v)
- Produces a normative form of the string representation of
an s-expression.
main
public static void main(String args[]) throws SExprParserException, IOException
All Packages Class Hierarchy This Package Previous Next Index