123456789101112131415161718192021222324252627282930313233343536373839openParser.MenhirInterpreteropenCoremoduleS=MenhirLib.Generalletpp_posout{Ppxlib.pos_lnum;pos_cnum;pos_bol;_}=Format.fprintfout"line %d:%d"pos_lnum(pos_cnum-pos_bol)lethandle_syntax_errorlexbuf=letmessage="Syntax error"inFormat.fprintfFormat.err_formatter"%s %a\n%!"messagepp_pos(fst@@Sedlexing.lexing_positionslexbuf)letrecloopnext_tokenlexbuf(checkpoint:Template.tcheckpoint)=matchcheckpointwith|InputNeeded_env->lettoken=next_token()inletcheckpoint=offercheckpointtokeninloopnext_tokenlexbufcheckpoint|Shifting_|AboutToReduce_->letcheckpoint=resumecheckpointinloopnext_tokenlexbufcheckpoint|HandlingError_->handle_syntax_errorlexbuf;None|Acceptedtemplate->Sometemplate|Rejected->(* Cannot happen as we stop at syntax error immediatly *)assertfalseletof_lexing_bufferlexbuf=letlexer=Lexer.lexerlexbufinlooplexerlexbuf(Parser.Incremental.template(fst@@Sedlexing.lexing_positionslexbuf))letof_ustringustring=of_lexing_buffer(Sedlexing.from_uchar_arrayustring)letof_stringstring=of_ustring(Ustring.of_stringstring)letof_filenamefilename=of_string(In_channel.read_allfilename)