updated lex with error states and parser