123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596openImportmoduleL=Ocaml_common.Locationtypet=location={loc_start:Lexing.position;loc_end:Lexing.position;loc_ghost:bool}letin_filename=letloc={pos_fname=name;pos_lnum=1;pos_bol=0;pos_cnum=-1}in{loc_start=loc;loc_end=loc;loc_ghost=true}letnone=in_file"_none_"letraise_errorf?locfmt=L.raise_errorf?locfmtletreport_exception=L.report_exceptionletof_lexbuf(lexbuf:Lexing.lexbuf)={loc_start=lexbuf.lex_start_p;loc_end=lexbuf.lex_curr_p;loc_ghost=false}letprintppft=Caml.Format.fprintfppf"File \"%s\", line %d, characters %d-%d:"t.loc_start.pos_fnamet.loc_start.pos_lnum(t.loc_start.pos_cnum-t.loc_start.pos_bol)(t.loc_end.pos_cnum-t.loc_start.pos_bol)typenonrec'aloc='aloc={txt:'a;loc:t}letcompare_posp1p2=letopenLexinginletcolumnp=(* Manual extract:
The difference between pos_cnum and pos_bol is the character offset
within the line (i.e. the column number, assuming each character is
one column wide). *)p.pos_cnum-p.pos_bolinmatchInt.comparep1.pos_lnump2.pos_lnumwith|0->Int.compare(columnp1)(columnp2)|n->nletmin_posp1p2=ifcompare_posp1p2<=0thenp1elsep2letmax_posp1p2=ifcompare_posp1p2>=0thenp1elsep2letcompareloc1loc2=matchcompare_posloc1.loc_startloc2.loc_startwith|0->compare_posloc1.loc_endloc2.loc_end|n->nmoduleError=structmoduleHelpers=Selected_ast.Ast.Ast_mappertypet=Helpers.location_errorletmake=Helpers.make_error_of_messageletcreatef~locfmt=Printf.ksprintf(funstr->Helpers.make_error_of_message~loc~sub:[]str)fmtletmessage=Helpers.get_error_messageletset_message=Helpers.set_error_messageletregister_error_of_exn=Helpers.register_error_of_exnletof_exn=Helpers.error_of_exnletto_extension=Helpers.extension_of_errorendexceptionErrorofError.tlet()=Caml.Printexc.register_printer(function|Errore->Some(Error.messagee)|_->None)