123456789101112131415161718192021222324252627282930313233343536373839404142includeOdoc_parser.Locletset_end_as_offset_from_startoffsetspan={spanwithend_={span.startwithcolumn=span.start.column+offset}}letpoint_in_stringsoffsetpoint=letrecscan_stringlinecolumnindex=ifindex>=offsetthen(line,column)elseifindex>=String.lengthsthen(line,column)elsematchs.[index]with|'\n'->scan_string(line+1)0(index+1)|_->scan_stringline(column+1)(index+1)inletline,column=scan_string000in{line=point.line+line;column=point.column+column}(* Calling this repeatedly on the same string can be optimized, but there is no
evidence yet that performance of this is a problem. *)letin_strings~offset~lengths_span={s_spanwithstart=point_in_stringsoffsets_span.start;end_=point_in_strings(offset+length)s_span.start;}letppfmtl=Format.fprintffmt"File \"%s\", "l.file;ifl.start.line=l.end_.linethenFormat.fprintffmt"line %i, characters %i-%i"l.start.linel.start.columnl.end_.columnelseFormat.fprintffmt"line %i, character %i to line %i, character %i"l.start.linel.start.columnl.end_.linel.end_.columnletpp_span_startfmts=Format.fprintffmt"File \"%s\", line %d, character %d"s.files.start.lines.start.columnletspan_equal=(=)