refactor parser_generator and removing unused var in check_parser