Modularize and reject invalid token type in the grammar