12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849(*********************************************************************************)(* Dunolint - A tool to lint and help manage files in dune projects *)(* Copyright (C) 2024-2025 Mathieu Barbin <mathieu.barbin@gmail.com> *)(* *)(* This file is part of Dunolint. *)(* *)(* Dunolint is free software; you can redistribute it and/or modify it *)(* under the terms of the GNU Lesser General Public License as published by *)(* the Free Software Foundation either version 3 of the License, or any later *)(* version, with the LGPL-3.0 Linking Exception. *)(* *)(* Dunolint is distributed in the hope that it will be useful, but WITHOUT *)(* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or *)(* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License *)(* and the file `NOTICE.md` at the root of this repository for more details. *)(* *)(* You should have received a copy of the GNU Lesser General Public License *)(* and the LGPL-3.0 Linking Exception along with this library. If not, see *)(* <http://www.gnu.org/licenses/> and <https://spdx.org>, respectively. *)(*********************************************************************************)letload_config_exn~filename=letcontents=In_channel.read_allfilenameinmatchParsexp.Many_and_positions.parse_stringcontentswith|Errorparse_error->letposition=Parsexp.Parse_error.positionparse_errorinletmessage=Parsexp.Parse_error.messageparse_errorinletloc=Sexp_handler.loc_of_parsexp_range~filename{start_pos=position;end_pos=position}inErr.raise~loc[Pp.textmessage]|Ok(sexps,positions)->(matchDunolint.Config.of_stanzassexpswith|t->t|exceptionSexp.Of_sexp_error(exn,sub)->letrange=matchParsexp.Positions.find_sub_sexp_in_list_physpositionssexps~subwith|Some_asrange->range|None->None[@coverageoff]inletloc=matchrangewith|Somerange->Sexp_handler.loc_of_parsexp_range~filenamerange|None->Loc.of_file~path:(Fpath.vfilename)[@coverageoff]inraise(Err.E(Sexp_handler.render_sexp_error_exn~locexn)));;