let of_stream ?(strict=true) f (cstr : char Stream.t) =
let lines = Stream.lines_of_chars cstr in
let g ans s =
try (f s)::ans
with Failure m ->
if strict
then raise_error (Pos.l (Stream.count lines)) m
else ans
in List.rev (Stream.fold g [] lines)