123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081(* This file is part of Markup.ml, released under the MIT license. See
LICENSE.md for details, or visit https://github.com/aantron/markup.ml. *)openCommontypet=[`Decoding_errorofstring*string|`Bad_tokenofstring*string*string|`Unexpected_eoiofstring|`Bad_documentofstring|`Unmatched_start_tagofstring|`Unmatched_end_tagofstring|`Bad_namespaceofstring|`Misnested_tagofstring*string*(string*string)list|`Bad_contentofstring]letexplode_strings=letreciterateindexacc=ifindex>=String.lengthsthenList.revaccelseiterate(index+1)(s.[index]::acc)initerate0[]letto_string?locationerror=letfmt=Printf.sprintfinletmessage=matcherrorwith|`Decoding_error(bytes,encoding)->beginmatchString.lengthbyteswith|0->fmt"bad bytes for encoding '%s'"encoding|1->fmt"bad byte '0x%02X' for encoding '%s'"(Char.codebytes.[0])encoding|_->fmt"bad bytes '%s' for encoding '%s'"(explode_stringbytes|>List.mapChar.code|>List.map(fmt"0x%02X")|>String.concat" ")encodingend|`Bad_token(s,production,reason)->fmt"bad token '%s' in %s: %s"sproductionreason|`Unexpected_eoiin_->fmt"unexpected end of input in %s"in_|`Bad_documentreason->fmt"bad document: %s"reason|`Unmatched_start_tags->fmt"unmatched start tag '%s'"s|`Unmatched_end_tags->fmt"unmatched end tag '%s'"s|`Bad_namespaces->fmt"unknown namespace '%s'"s|`Misnested_tag(s,in_,_attributes)->fmt"misnested tag: '%s' in '%s'"sin_|`Bad_contents->fmt"bad content in '%s'"sinmatchlocationwith|None->message|Some(line,column)->fmt"line %i, column %i: %s"linecolumnmessagetype'ahandler='a->t->unitcpstypeparse_handler=locationhandlertypewrite_handler=(signal*int)handlerletignore_errors___resume=resume()letreport_ifreportconditionlocationdetailthrowk=ifconditionthenreportlocation(detail())throwkelsek()