Class StringParsingTask<E>


  • public abstract class StringParsingTask<E>
    extends 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
    • Field Detail

      • index

        protected int index
      • isEOF

        protected boolean isEOF
    • Constructor Detail

      • StringParsingTask

        public StringParsingTask​(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.
      • 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)