let feed_string p s =
let lines = String.split s ~on:'\n' in
let rec faux = function
| [] -> assert false
| [ "" ] -> (* last char was a "\n" *) ()
| [ s ] -> (* there is a partial line at the end *)
p.unfinished_line <- Some s;
| h :: t ->
Queue.enqueue p.lines (Line.of_string_unsafe h);
faux t
in
match p.unfinished_line, lines with
| _, [] -> assert false
| _, [""] -> ()
| None, l -> faux l
| Some s, h :: t ->
p.unfinished_line <- None;
faux ((s ^ h) :: t)