Pulled out type code into separate module for code sharing between scanner->parser.