public abstract class StringParsingTask<E>
extends java.lang.Object
String
and
returns an object of type E
. It's called a
StringParsingTask
(rather than StringParser
)
because a new instance is constructed for each String
to be
parsed. We do this to be thread-safe: methods in
StringParsingTask
share state information (e.g. current
string index) via instance variables.Modifier and Type | Class and Description |
---|---|
static class |
StringParsingTask.ParserException |
Modifier and Type | Field and Description |
---|---|
protected int |
index |
protected boolean |
isEOF |
protected java.lang.String |
s |
Constructor and Description |
---|
StringParsingTask(java.lang.String s)
Constructs a new
StringParsingTask from the specified
String . |
Modifier and Type | Method and Description |
---|---|
protected boolean |
isDot(char ch) |
protected boolean |
isEOF() |
protected boolean |
isLeftParen(char ch) |
protected boolean |
isPunct(char ch) |
protected boolean |
isRightParen(char ch) |
protected boolean |
isWhiteSpace(char ch) |
abstract E |
parse()
Parses the
String associated with this
StringParsingTask and returns a object of type
E . |
protected char |
peek() |
protected char |
read() |
protected void |
readDot() |
protected java.lang.String |
readJavaIdentifier() |
protected void |
readLeftParen() |
protected java.lang.String |
readName()
|
protected void |
readRightParen() |
protected void |
readWhiteSpace() |
protected void |
unread() |
public StringParsingTask(java.lang.String s)
StringParsingTask
from the specified
String
. Derived class constructors should be sure to
call super(s)
!public abstract E parse()
String
associated with this
StringParsingTask
and returns a object of type
E
.protected java.lang.String readName()
isWhiteSpace(ch)
or
isPunct(ch)
or isEOF()
. You may need
to override the definition of isPunct(ch)
to
get this to work right.protected java.lang.String readJavaIdentifier()
protected void readLeftParen()
protected void readRightParen()
protected void readDot()
protected void readWhiteSpace()
protected char read()
protected void unread()
protected char peek()
protected boolean isEOF()
protected boolean isWhiteSpace(char ch)
protected boolean isPunct(char ch)
protected boolean isLeftParen(char ch)
protected boolean isRightParen(char ch)
protected boolean isDot(char ch)