|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object
|
+--java.io.InputStream
|
+--java.io.FilterInputStream
|
+--java.io.PushbackInputStream
|
+--org.w3c.tools.sexpr.SimpleSExprStream
Basic implementation of the SExprStream parser interface.
| Field Summary |
| Fields inherited from class java.io.PushbackInputStream |
buf, pos |
| Fields inherited from class java.io.FilterInputStream |
in |
| Constructor Summary | |
SimpleSExprStream(java.io.InputStream input)
Initializes the parser with no read table and no symbol table assigned. |
|
| Method Summary | |
SExprParser |
addParser(char key,
SExprParser parser)
Associates a dispatch character with a parser in the read table. |
boolean |
getListsAsVectors()
Checks whether lists should be parsed as Vectors or Cons cells. |
Readtable |
getReadtable()
Accesses the read table of the parser. |
java.lang.StringBuffer |
getScratchBuffer()
Accesses an empty string buffer available temporary storage. |
java.util.Dictionary |
getSymbols()
Accesses the symbol table of the parser. |
protected boolean |
isAtomChar(char c,
boolean first)
Predicate function for checking if a chahracter can belong to an atom. |
static void |
main(java.lang.String[] args)
|
protected java.lang.Number |
makeNumber(java.lang.String s)
Attempts to parse a number from the string. |
java.lang.Object |
parse()
Parses a single object from the underlying input stream. |
java.lang.Object |
parse(char c,
SExprStream stream)
Parses a single object started by the character c. |
protected java.lang.Object |
parseAtom(char c)
Parses an atom (a number or a symbol). |
protected Cons |
parseList()
Parses a list (as Cons cells) sans first character. |
java.lang.String |
parseString()
Parses a double-quote -delimited string (sans the first character). |
protected java.util.Vector |
parseVector(java.util.Vector vector,
char delimiter)
Parses a list (as a Vector) sans first character. |
static void |
printExpr(java.lang.Object expr,
java.io.PrintStream out)
Produces a printed representation of an s-expression. |
char |
readSkipWhite()
Reads from the stream, skipping whitespace and comments. |
boolean |
setListsAsVectors(boolean listsAsVectors)
Controls whether lists are represented as Vectors or Cons cells. |
Readtable |
setReadtable(Readtable readtable)
Assigns a new read table to the parser. |
java.util.Dictionary |
setSymbols(java.util.Dictionary symbols)
Assigns a symbol table to the parser. |
| Methods inherited from class java.io.PushbackInputStream |
available, close, markSupported, read, read, skip, unread, unread, unread |
| Methods inherited from class java.io.FilterInputStream |
mark, read, reset |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface org.w3c.tools.sexpr.SExprStream |
read |
| Constructor Detail |
public SimpleSExprStream(java.io.InputStream input)
| Method Detail |
public java.util.Dictionary getSymbols()
getSymbols in interface SExprStreampublic java.util.Dictionary setSymbols(java.util.Dictionary symbols)
setSymbols in interface SExprStreampublic Readtable getReadtable()
getReadtable in interface SExprStreampublic Readtable setReadtable(Readtable readtable)
setReadtable in interface SExprStreampublic boolean getListsAsVectors()
getListsAsVectors in interface SExprStreampublic boolean setListsAsVectors(boolean listsAsVectors)
setListsAsVectors in interface SExprStreampublic java.lang.StringBuffer getScratchBuffer()
getScratchBuffer in interface SExprStream
public java.lang.Object parse()
throws SExprParserException,
java.io.IOException
parse in interface SExprStreamSExprParserException - if syntax error was detected
java.io.IOException - if any other I/O-related problem occurred
public java.lang.Object parse(char c,
SExprStream stream)
throws SExprParserException,
java.io.IOException
parse in interface SExprParserSExprParserException - if syntax error was detected
java.io.IOException - if any other I/O-related problem occurred
protected Cons parseList()
throws SExprParserException,
java.io.IOException
SExprParserException - if syntax error was detected
java.io.IOException - if any other I/O-related problem occurred
protected java.util.Vector parseVector(java.util.Vector vector,
char delimiter)
throws SExprParserException,
java.io.IOException
SExprParserException - if syntax error was detected
java.io.IOException - if any other I/O-related problem occurred
protected java.lang.Object parseAtom(char c)
throws SExprParserException,
java.io.IOException
SExprParserException - not signalled but useful for the protocol
java.io.IOException - if an I/O problem occurred (e.g. end of file)
public java.lang.String parseString()
throws SExprParserException,
java.io.IOException
SExprParserException - not signalled but useful for the protocol
java.io.IOException - any I/O problem (including end of file)
protected boolean isAtomChar(char c,
boolean first)
first - if true means that c is the first character of the atom
public char readSkipWhite()
throws java.io.IOException
readSkipWhite in interface SExprStreamjava.io.IOException - if an I/O problem occurred (including end of file)
protected java.lang.Number makeNumber(java.lang.String s)
throws java.lang.NumberFormatException
java.lang.NumberFormatException - the string does not represent a number
public SExprParser addParser(char key,
SExprParser parser)
addParser in interface SExprStream
public static void printExpr(java.lang.Object expr,
java.io.PrintStream out)
public static void main(java.lang.String[] args)
throws SExprParserException,
java.io.IOException
SExprParserException
java.io.IOException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||