We may want to do some actual hacking on TokenStream.java in class, so I'm linking
here a version with enough commented out that it compiles, to serve as
a starting point for more serious work. (I also changed the way EOF
is reported by nextToken
. Rather than returning
null
, it now returns a special type of token. That will
make the parser simpler.)
Possible discussion topics include:
Making this program do something (anything).
What the special Java magic is for writing whitespace characters.
Can isLetter
be written without 52 individual comparisons?.
How this program uses exceptions, and how that contrasts with Tucker and Noonan's version. This also includes the question of why neither version uses a exception to report the end of file.
The question we didn't get to on Friday that was listed on the
notes for that day: Even after I got done improving the Token
class, it still has at least one problem. This class inherits
the definitions of the equals
and hashCode
methods from the Object
class, rather than overriding
those definitions with its own. Why is that a problem? What should
the definitions be?