itp_communication.ml 4.36 KB
Newer Older
Sylvain Dailler's avatar
Sylvain Dailler committed
1 2 3 4 5 6 7 8 9 10 11 12
(* Information that the IDE may want to have *)
type prover = string
type transformation = string
type strategy = string


type node_ID = int
let root_node : node_ID = 0


type global_information =
    {
MARCHE Claude's avatar
MARCHE Claude committed
13
     provers         : (string * prover) list;
Sylvain Dailler's avatar
Sylvain Dailler committed
14 15 16 17 18 19 20 21 22 23 24 25 26
     transformations : transformation list;
     strategies      : strategy list;
     commands        : string list;
     (* hidden_provers       : string list; *)
     (* session_time_limit   : int; *)
     (* session_mem_limit    : int; *)
     (* session_nb_processes : int; *)
     (* session_cntexample   : bool; *)
     (* main_dir             : string *)
    }

type message_notification =
  | Proof_error           of node_ID * string
27 28
  | Transf_error          of node_ID * string * string * Loc.position * string
  (* Transf_error (nid, trans_with_arg, arg_opt, loc, error_msg *)
Sylvain Dailler's avatar
Sylvain Dailler committed
29 30 31 32 33 34 35
  | Strat_error           of node_ID * string
  | Replay_Info           of string
  | Query_Info            of node_ID * string
  | Query_Error           of node_ID * string
  | Help                  of string
  | Information           of string
  | Task_Monitor          of int * int * int
Sylvain Dailler's avatar
Sylvain Dailler committed
36
  | Parse_Or_Type_Error   of Loc.position * string
37
  | File_Saved            of string
Sylvain Dailler's avatar
Sylvain Dailler committed
38 39 40 41 42 43 44 45 46 47 48
  | Error                 of string
  | Open_File_Error       of string

type node_type =
  | NRoot
  | NFile
  | NTheory
  | NTransformation
  | NGoal
  | NProofAttempt

49 50 51 52 53 54 55 56
(* Used to give colors to the parts of the source code that corresponds to the
   following property in the current task. For example, the code corresponding
   to the goal of the task will have Goal_color in the source code. *)
type color =
  | Neg_premise_color
  | Premise_color
  | Goal_color

Sylvain Dailler's avatar
Sylvain Dailler committed
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
type update_info =
  | Proved of bool
  | Proof_status_change of
      Controller_itp.proof_attempt_status
      * bool   (* obsolete or not *)
      * Call_provers.resource_limit

type notification =
  | New_node     of node_ID * node_ID * node_type * string * bool
  (* Notification of creation of new_node:
     New_node (new_node, parent_node, node_type, name, detached). *)
  | Node_change  of node_ID * update_info
  (* inform that the data of the given node changed *)
  | Remove       of node_ID
  (* the given node was removed *)
72 73 74
  | Next_Unproven_Node_Id of node_ID * node_ID
  (* Next_Unproven_Node_Id (asked_id, next_unproved_id). Returns a node and the
     next unproven node from this node *)
Sylvain Dailler's avatar
Sylvain Dailler committed
75 76 77 78 79 80 81 82
  | Initialized  of global_information
  (* initial global data *)
  | Saved
  (* the session was saved on disk *)
  | Message      of message_notification
  (* an informative message, can be an error message *)
  | Dead         of string
  (* server exited *)
83 84 85 86
  | Task         of node_ID * string * (Loc.position * color) list
  (* the node_ID's task together with information that allows to color the
     source code corresponding to different part of the task (premise, goal,
     etc) *)
87
  | File_contents of string * string
88
  (* File_contents (filename, contents) *)
Sylvain Dailler's avatar
Sylvain Dailler committed
89 90

type ide_request =
91 92 93 94
  | Command_req             of node_ID * string
  | Prove_req               of node_ID * prover * Call_provers.resource_limit
  | Transform_req           of node_ID * transformation * string list
  | Strategy_req            of node_ID * strategy
Sylvain Dailler's avatar
Sylvain Dailler committed
95
  | Edit_req                of node_ID * prover
96
(*
97
  | Open_session_req        of string
98
 *)
99 100 101 102
  | Add_file_req            of string
  | Set_max_tasks_req       of int
  | Get_file_contents       of string
  | Get_task                of node_ID
Sylvain Dailler's avatar
Sylvain Dailler committed
103 104
  | Focus_req               of node_ID
  | Unfocus_req
105 106 107
  | Remove_subtree          of node_ID
  | Copy_paste              of node_ID * node_ID
  | Copy_detached           of node_ID
108
  | Save_file_req           of string * string
109
  | Get_first_unproven_node of node_ID
110
  | Mark_obsolete_req       of node_ID
Sylvain Dailler's avatar
Sylvain Dailler committed
111
  | Get_Session_Tree_req
112
  | Clean_req
Sylvain Dailler's avatar
Sylvain Dailler committed
113 114 115 116
  | Save_req
  | Reload_req
  | Replay_req
  | Exit_req
117
  | Interrupt_req
118 119 120 121 122 123

(* Return true if the request modify the session *)
let modify_session (r: ide_request) =
  match r with
  | Command_req _ | Prove_req _ | Transform_req _ | Strategy_req _
  | Add_file_req _ | Remove_subtree _ | Copy_paste _ | Copy_detached _
Sylvain Dailler's avatar
Sylvain Dailler committed
124
  | Replay_req | Clean_req | Mark_obsolete_req _ | Edit_req _ -> true
125

126 127
  (*| Open_session_req _ *)
  | Set_max_tasks_req _ | Get_file_contents _
128 129
  | Get_task _ | Save_file_req _ | Get_first_unproven_node _
  | Get_Session_Tree_req | Save_req | Reload_req | Exit_req
Sylvain Dailler's avatar
Sylvain Dailler committed
130
  | Interrupt_req | Focus_req _ | Unfocus_req -> false