Added error handling in lexer and parser