edu.stanford.nlp.util
Class StringParsingTask<E>

java.lang.Object
  extended by edu.stanford.nlp.util.StringParsingTask<E>

public abstract class StringParsingTask<E>
extends java.lang.Object

An instantiation of this abstract class parses a 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.

Author:
Bill MacCartney

Nested Class Summary
static class StringParsingTask.ParserException
           
 
Field Summary
protected  int index
           
protected  boolean isEOF
           
protected  java.lang.String s
           
 
Constructor Summary
StringParsingTask(java.lang.String s)
          Constructs a new StringParsingTask from the specified String.
 
Method Summary
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()
          Reads characters until isWhiteSpace(ch)or isPunct(ch) or isEOF().
protected  void readRightParen()
           
protected  void readWhiteSpace()
           
protected  void unread()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

s

protected java.lang.String s

index

protected int index

isEOF

protected boolean isEOF
Constructor Detail

StringParsingTask

public StringParsingTask(java.lang.String s)
Constructs a new StringParsingTask from the specified String. Derived class constructors should be sure to call super(s)!

Method Detail

parse

public abstract E parse()
Parses the String associated with this StringParsingTask and returns a object of type E.


readName

protected java.lang.String readName()
Reads characters until isWhiteSpace(ch)or isPunct(ch) or isEOF(). You may need to override the definition of isPunct(ch) to get this to work right.


readJavaIdentifier

protected java.lang.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)


Stanford NLP Group