1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253openCoremoduleState=structtypet=[`Header(** Initial state, parsing headers *)|`Content(** Parsing the body of the message. The details are in the body state. *)|`Expected_eof(** The message should end here. If it doesn't, it's an error *)]letinitial=`HeaderendmoduleContent=structtypet=|Multipartofstringlist|Octet_streamletdefault=Octet_streamendtypet={mutablestate:State.t;buf:Email_grammar.tokenQueue.t}letcreate()={state=State.initial;buf=Queue.create()}moduleResult=structtypet={new_state:State.toption;tokens:Email_grammar.tokenlist}moduleStd=structletreturn?new_statetokens={new_state;tokens}letreturn_eof=return~new_state:`Expected_eof[Email_grammar.EOF]letreturn_errorstr=return[Email_grammar.ERRORstr]endendletcombinetresult=(matchresult.Result.new_statewith|Somestate->t.state<-state|None->());List.iterresult.Result.tokens~f:(funtok->Queue.enqueuet.buftok);;includeResult.StdmoduleError=structletunexpected_charc=sprintf"Unexpected char: %c"cletunexpected_eof="Unexpected end of file"end