let of_channel = fun ?(close = true) channel ->
  try
    of_lexbuf (Lexing.from_channel channel)
  with
    | e -> begin
        (try  if close then Pervasives.close_in channel
         with _ -> ());
        raise e
      end