Package edu.stanford.nlp.util
Class StringParsingTask<E>
- java.lang.Object
-
- edu.stanford.nlp.util.StringParsingTask<E>
-
public abstract class StringParsingTask<E> extends Object
An instantiation of this abstract class parses aStringand returns an object of typeE. It's called aStringParsingTask(rather thanStringParser) because a new instance is constructed for eachStringto be parsed. We do this to be thread-safe: methods inStringParsingTaskshare state information (e.g. current string index) via instance variables.- Author:
- Bill MacCartney
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classStringParsingTask.ParserException
-
Constructor Summary
Constructors Constructor Description StringParsingTask(String s)Constructs a newStringParsingTaskfrom the specifiedString.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected booleanisDot(char ch)protected booleanisEOF()protected booleanisLeftParen(char ch)protected booleanisPunct(char ch)protected booleanisRightParen(char ch)protected booleanisWhiteSpace(char ch)abstract Eparse()Parses theStringassociated with thisStringParsingTaskand returns a object of typeE.protected charpeek()protected charread()protected voidreadDot()protected StringreadJavaIdentifier()protected voidreadLeftParen()protected StringreadName()protected voidreadRightParen()protected voidreadWhiteSpace()protected voidunread()
-
-
-
Field Detail
-
s
protected String s
-
index
protected int index
-
isEOF
protected boolean isEOF
-
-
Constructor Detail
-
StringParsingTask
public StringParsingTask(String s)
Constructs a newStringParsingTaskfrom the specifiedString. Derived class constructors should be sure to callsuper(s)!
-
-
Method Detail
-
parse
public abstract E parse()
Parses theStringassociated with thisStringParsingTaskand returns a object of typeE.
-
readName
protected String readName()
Reads characters untilisWhiteSpace(ch)orisPunct(ch)orisEOF(). You may need to override the definition ofisPunct(ch)to get this to work right.
-
readJavaIdentifier
protected String readJavaIdentifier()
-
readLeftParen
protected void readLeftParen()
-
readRightParen
protected void readRightParen()
-
readDot
protected void readDot()
-
readWhiteSpace
protected void readWhiteSpace()
-
read
protected char read()
-
unread
protected void unread()
-
peek
protected char peek()
-
isEOF
protected boolean isEOF()
-
isWhiteSpace
protected boolean isWhiteSpace(char ch)
-
isPunct
protected boolean isPunct(char ch)
-
isLeftParen
protected boolean isLeftParen(char ch)
-
isRightParen
protected boolean isRightParen(char ch)
-
isDot
protected boolean isDot(char ch)
-
-