convert parse_gcode to generator

There is no need to read the whole file at once.