parser: implement parse_loop