12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485(* This file is part of Bisect_ppx, released under the MIT license. See
LICENSE.md for details, or visit
https://github.com/aantron/bisect_ppx/blob/master/LICENSE.md. *)typet=|Regular_expressionofStr.regexp|Exclude_fileofExclude.fileletexcluded=ref[]letfunction_separator=Str.regexp"[ \t]*,[ \t]*"letadds=letpatterns=Str.splitfunction_separatorsinletpatterns=List.map(funx->Regular_expression(Str.regexpx))patternsinexcluded:=patterns@!excludedletadd_files=letpattern=Exclude.{path=Regexp(Str.regexps);exclusions=None}inexcluded:=(Exclude_filepattern)::!excludedletadd_from_channelfilenamech=letlexbuf=Lexing.from_channelchintryletres=Exclude_parser.fileExclude_lexer.tokenlexbufinletres=List.map(funx->Exclude_filex)resinexcluded:=res@!excluded;close_in_noerrchwith|Exclude.Exception(line,msg)->Printf.eprintf" *** error in file %S at line %d: %s\n"filenamelinemsg;close_in_noerrch;exit1|e->close_in_noerrch;raiseeletadd_from_filefilename=(* BuckleScript runs the PPX from PROJECT_ROOT/lib/bs. *)letcwd=Sys.getcwd()inletparent=Filename.basenamecwdinletgrandparent=Filename.(basename(dirnamecwd))inletchannel=ifgrandparent="lib"&&parent="bs"thentryopen_in(Filename.(concat(dirname(dirnamecwd)))filename)withSys_error_->open_infilenameelseopen_infilenameinadd_from_channelfilenamechannelletmatch_patternpatternname=Str.string_matchpatternname0&&Str.match_end()=String.lengthnameletfile_name_matchesexclusionfile=matchexclusion.Exclude.pathwith|Exclude.Namefile'->file=file'|Exclude.Regexppattern->match_patternpatternfileletcontains_valuefilename=List.exists(function|Regular_expressionpatt->match_patternpattname|Exclude_fileef->letin_value_list()=matchef.Exclude.exclusionswith|None->true|Someexclusions->exclusions|>List.exists(function|Exclude.Nameen->name=en|Exclude.Regexppatt->match_patternpattname)infile_name_matcheseffile&&in_value_list())!excludedletcontains_filefile=!excluded|>List.exists(function|Regular_expression_->false|Exclude_fileexclusion->exclusion.Exclude.exclusions=None&&file_name_matchesexclusionfile)