Improve lexer to throw an error on invalid input.