CS241: Spring 2017 -- Expression evaluation - inputing a series of tokens with a StringTokenizer

  1. Conway eaters
  2. Vocabulary! Two compiler writer terms and one OOP term:
    1. token - smallest meaningful unit of input
    2. emit - output; allows simple redirection of output
    3. wrapper - short for wrapper class, a convenience class that wraps up another class in a way that makes using it convenient
  3. MyReader - to read files; a wrapper for a BufferedReader
  4. StringTokenizer - to split Strings into tokens. Three constructors:
    1. StringTokenizer(String) uses whitespace as the only delimiter, returns tokens from the String delimited by whitespace
    2. StringTokenizer(String, String) uses chars in the second String as delimiters, returns tokens delimited by them
    3. StringTokenizer(String, String, true) as above, but returns the delimiters as tokens too
    4. ...so new StringTokenizer("foo") could also be written as new StringTokenizer("foo", " ", false)
  5. Example: What sequence of tokens will this give? new StringTokenizer("3 2 - 1 +", " *-/+", true);? Test code:
    1. Write code that is simple and understandable (i.e. use good style!)
      1. Write little bits of code before big bits! Test a little at a time.
      2. Use constants
      3. Use delimiters on String output, so you can tell and empty String from one with just whitespace (or non-printing characters)
      4. Write methods so everything stays simple
    2. Control! Three reserved words that modify loop/method behavior:
      1. return -- returns to where the method was invoked
      2. break -- goes out the bottom of the loop (or construct)
      3. continue -- goes back to the top of the loop
  6. Finishing GreatBigInt, and then using it to compute Fibonacci(100). The process of building software.
    1. Representation -- ArrayList<Integer>, with one digit in each, least significant first
    2. Initialization -- addDigit(int)
    3. Display
    4. GreatBigInt add(GreatBigInt that) -- returns the sum of this and that
      1. this and that have the same number of digits
      2. this has more digits than that
      3. that has more digits than this
      4. carry