| CIT
594 Change in Type and Tokenizer Classes Spring 2006, David Matuszek |
The current assignment requires some minor changes in the Type
and Tokenizer classes. My apologies; I can't forsee everything.
Fortunately, you should have good JUnit tests, so these modifications should
not be painful. They took me about 20 minutes, and that includes writing
up this page.
TypeAdd a new type END_OF_INPUT.
The type END_OF_INPUT will have the same meaning as the type EOL
did in the original assignment. EOL will now mean "end of
line", that is, a newline character, '\n'. That's how I should
have defined it all along. Please update your Javadoc comments to reflect this
change.
TokenIt is unlikely that you will have to change Token class.
Tokenizer (and TokenizerTest)Start by updating TokenizerTest. Basically, this requires two
steps:
EOL token with tests for an END_OF_INPUT
token.Don't forget to run your tests and make sure they fail!
Now update your Tokenizer. For me, this meant adding a couple
of lines to my state machine's initial state, changing my skipWhitespace()
method to not skip over newlines, and changing next() to return
END_OF_INPUT instead of EOL when it reached the end
of the input.
Use JUnit to make sure your updated Tokenizer works properly.