123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110(*********************************************************************************)(* 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. *)(*********************************************************************************)open!ImportmoduleRule=structtypet=(Predicate.t,Condition.t)Rule.Stable.V1.tletequal(a:t)(b:t)=Rule.Stable.V1.equalPredicate.equalCondition.equalablett_of_sexpsexp=Rule.Stable.V1.t_of_sexpPredicate.t_of_sexpCondition.t_of_sexpsexp;;letsexp_of_tt=Rule.Stable.V1.sexp_of_tPredicate.sexp_of_tCondition.sexp_of_ttendmoduleStanza=structleterror_source="config.v1.stanza.t"typet=[`skip_pathsofGlob.tlist|`ruleofRule.t]letequal(a:t)(b:t)=ifphys_equalabthentrueelse(matcha,bwith|`skip_pathsva,`skip_pathsvb->equal_listGlob.equalvavb|`ruleva,`rulevb->Rule.equalvavb|(`skip_paths_|`rule_),_->false);;letvariant_spec:tSexp_helpers.Variant_spec.t=[{atom="skip_paths";conv=Variadic(fun~context:_~fields->`skip_paths(List.mapfields~f:Glob.t_of_sexp))};{atom="rule";conv=Unary(funsexp->`rule(Rule.t_of_sexpsexp))}];;lett_of_sexp(sexp:Sexp.t):t=Sexp_helpers.parse_variantvariant_spec~error_sourcesexp;;letsexp_of_t(t:t):Sexp.t=matchtwith|`skip_pathsv->List(Atom"skip_paths"::List.mapv~f:Glob.sexp_of_t)|`rulev->List[Atom"rule";Rule.sexp_of_tv];;endtypet={stanzas:Stanza.tlist}letequal(a:t)(b:t)=ifphys_equalabthentrueelse(let{stanzas}=binequal_listStanza.equala.stanzasstanzas);;letsexp_of_t{stanzas}=Sexp.List[List[Atom"stanzas";sexp_of_listStanza.sexp_of_tstanzas]];;letof_stanzassexps=letstanzas=List.mapsexps~f:Stanza.t_of_sexpin{stanzas};;letto_stanzas{stanzas}=List.mapstanzas~f:Stanza.sexp_of_tletskip_pathst=List.filter_mapt.stanzas~f:(function|`skip_pathsglobs->Someglobs|`rule_->None);;letrulest=List.filter_mapt.stanzas~f:(function|`rulerule->Somerule|`skip_paths_->None);;letcreatestanzas={stanzas}moduleStd=Edsl_std