Additional refactoring for the lexer/parser.

This is part of an ongoing effort to clean up the code and make it more
readable.