1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465(**************************************************************************)(* *)(* Copyright 2011 Jun Furuse *)(* Copyright 2012 OCamlPro *)(* *)(* All rights reserved.This file is distributed under the terms of the *)(* GNU Lesser General Public License version 2.1 with linking *)(* exception. *)(* *)(* TypeRex 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 *)(* Lesser GNU General Public License for more details. *)(* *)(**************************************************************************)modulePosition=structtypet=Lexing.position={pos_fname:string;pos_lnum:int;pos_bol:int;pos_cnum:int;}letto_stringt=Printf.sprintf"%s%d:%d"(ift.pos_fname=""then""elset.pos_fname^":")t.pos_lnum(t.pos_cnum-t.pos_bol)letzero={pos_fname="";pos_lnum=1;pos_bol=0;pos_cnum=0}letcolumnp=p.pos_cnum-p.pos_bolendmoduleRegion=structopenPositiontypet=Position.t*Position.tletfst=fstletsnd=sndletcreatep1p2=(p1,p2)letstart_column(p,_)=columnpletend_column(_,p)=columnpletstart_line(p,_)=p.pos_lnumletend_line(_,p)=p.pos_lnumletchar_offset(p,_)=p.pos_cnumletlength(p1,p2)=p2.Position.pos_cnum-p1.Position.pos_cnumletzero=(Position.zero,Position.zero)lettranslate(p,p')diff={pwithpos_cnum=p.pos_cnum+diff},{p'withpos_cnum=p'.pos_cnum+diff}end