changed placement of error counting and lexeme reading