1234567891011121314151617181920212223242526272829303132letversion="2.2.2"exceptionJson_errorofstringletjson_errors=raise(Json_errors)exceptionEnd_of_arrayexceptionEnd_of_objectexceptionEnd_of_tupleexceptionEnd_of_inputtypelexer_state={buf:Buffer.t;(* Buffer used to accumulate substrings *)mutablelnum:int;(* Current line number (starting from 1) *)mutablebol:int;(* Absolute position of the first character of the current line
(starting from 0) *)mutablefname:stringoption;(* Name describing the input file *)}moduleLexer_state=structtypet=lexer_state={buf:Buffer.t;mutablelnum:int;mutablebol:int;mutablefname:stringoption;}endletinit_lexer?buf?fname?(lnum=1)()=letbuf=matchbufwithNone->Buffer.create256|Somebuf->bufin{buf;lnum;bol=0;fname}