1234567891011121314151617181920212223242526272829303132moduleParsable=Pcoq.Parsableletparse~stps=letmode=State.mode~stinletst=State.parsing~stin(* Coq is missing this, so we add it here. Note that this MUST run inside
coq_protect *)Control.check_for_interrupt();Vernacstate.Parser.parsestPvernac.(main_entrymode)ps|>Option.mapAst.of_coqletparse~stps=Protect.eval~f:(parse~st)ps(* Read the input stream until a dot or a "end of proof" token is encountered *)letparse_to_terminator:unitPcoq.Entry.t=(* type 'a parser_fun = { parser_fun : te LStream.t -> 'a } *)letrecdotkwstatest=matchGramlib.LStream.nextkwstatestwith|Tok.KEYWORD("."|"..."|"Qed"|"Defined"|"Admitted")|Tok.BULLET_->()|Tok.EOI->()|_->dotkwstatestinPcoq.Entry.of_parser"Coqtoplevel.dot"{parser_fun=dot}(* If an error occurred while parsing, we try to read the input until a dot
token is encountered. We assume that when a lexer error occurs, at least one
char was eaten *)letrecdiscard_to_dotps=tryPcoq.Entry.parseparse_to_terminatorpswith|CLexer.Error.E_->discard_to_dotps|ewhenCErrors.noncriticale->()