12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879(************************************************************************)(* * The Coq Proof Assistant / The Coq Development Team *)(* v * Copyright INRIA, CNRS and contributors *)(* <O___,, * (see version control and CREDITS file for authors & dates) *)(* \VV/ **************************************************************)(* // * This file is distributed under the terms of the *)(* * GNU Lesser General Public License Version 2.1 *)(* * (see LICENSE file for the text of the license) *)(************************************************************************)(** Ltac debugger interface; clients should register hooks to interact
with their provided interface. *)moduleAction=structtypet=|Step(** Step one tactic *)|Skip(** Skip one tactic *)|Exit|Help|RunCntofint|RunBreakpointofstring|Failed(* XXX: Could we move this to the CString utility library? *)letpossibly_unquotes=ifString.lengths>=2&&s.[0]=='"'&&s.[String.lengths-1]=='"'thenString.subs1(String.lengths-2)elsesletparse_complexinst:(t,string)result=if'r'=String.getinst0thenletarg=String.(trim(subinst1(lengthinst-1)))inifarg<>""thenmatchint_of_string_optargwith|Somenum->ifnum<0thenError"number must be positive"elseOk(RunCntnum)|None->Ok(RunBreakpoint(possibly_unquotearg))elseError("invalid input: "^inst)elseError("invalid input: "^inst)(* XXX: Should be moved to the clients *)letparseinst:(t,string)result=matchinstwith|""->OkStep|"s"->OkSkip|"x"->OkExit|"h"|"?"->OkHelp|_->parse_complexinstendmoduleAnswer=structtypet=|PromptofPp.t|GoalofPp.t|OutputofPp.tendmoduleIntf=structtypet={read_cmd:unit->Action.t(** request a debugger command from the client *);submit_answer:Answer.t->unit(** receive a debugger answer from Ltac *)}letltac_debug_ref:toptionref=refNoneletsethooks=ltac_debug_ref:=Somehooksletget()=!ltac_debug_refend