Add comments for Undo, get_instr
This commit is contained in:
parent
b17a1c3662
commit
e6680b181c
1
hlam.ml
1
hlam.ml
@ -14,6 +14,7 @@ type hlam = (* hollow lam *)
|
|||||||
| Hole
|
| Hole
|
||||||
|
|
||||||
|
|
||||||
|
(* avec assoc la liste d'associations anciennes ref -> nouvelles ref, remplacer toutes les ref *)
|
||||||
let clean_hlam assoc (h : hlam) : hlam =
|
let clean_hlam assoc (h : hlam) : hlam =
|
||||||
let rec clean (h : hlam) : hlam= match h with
|
let rec clean (h : hlam) : hlam= match h with
|
||||||
HFun ((s, t), h) -> HFun ((s, t), clean h)
|
HFun ((s, t), h) -> HFun ((s, t), clean h)
|
||||||
|
14
main.ml
14
main.ml
@ -44,7 +44,9 @@ let rec beta_reduce (l : Lam.lam) =
|
|||||||
| None -> l
|
| None -> l
|
||||||
| Some l' -> beta_reduce l'
|
| Some l' -> beta_reduce l'
|
||||||
|
|
||||||
|
(* copier l'entièreté de l'état d'une preuve avec de nouvelles références pour le Undo *)
|
||||||
let clean_state ((s, p) : interactive_state) =
|
let clean_state ((s, p) : interactive_state) =
|
||||||
|
(* assoc fait le lien entre les anciennes et nouvelles ref, doit être commun au terme et aux différents composants de la preuve *)
|
||||||
let assoc, new_p = clean_proof p in
|
let assoc, new_p = clean_proof p in
|
||||||
match s with
|
match s with
|
||||||
| None -> None, new_p
|
| None -> None, new_p
|
||||||
@ -114,19 +116,19 @@ let rec interactive (get_instr : unit -> instr) (sl : (interactive_state) list)
|
|||||||
| s::sq -> s, sq
|
| s::sq -> s, sq
|
||||||
in
|
in
|
||||||
begin
|
begin
|
||||||
let _ = match g with
|
let _ = match g with (* affichage de l'état de la preuve *)
|
||||||
None -> print_string "\n\027[1mNo more goals.\027[0m\n"
|
None -> print_string "\n\027[1mNo more goals.\027[0m\n"
|
||||||
| Some g' -> print_newline (); print_goal g'
|
| Some g' -> print_newline (); print_goal g'
|
||||||
in
|
in
|
||||||
|
|
||||||
try
|
try
|
||||||
match get_instr () with
|
match get_instr () with (* get_instr récupère l'instruction suivante depuis un fichier ou stdin (garde en buffer les lignes doubles notamment) *)
|
||||||
Cmd c ->
|
Cmd c ->
|
||||||
begin match c with
|
begin match c with
|
||||||
Goal ty ->
|
Goal ty ->
|
||||||
let rh = Ref (ref Hole) in
|
let rh = Ref (ref Hole) in
|
||||||
[Some (rh, ty), (Some (rh, ty, []), [])] |> interactive get_instr
|
[Some (rh, ty), (Some (rh, ty, []), [])] |> interactive get_instr
|
||||||
| Undo -> interactive get_instr sq
|
| Undo -> interactive get_instr sq (* pour Undo, on appelle juste interactive en supprimant le dernier état *)
|
||||||
| Qed -> begin match cg with
|
| Qed -> begin match cg with
|
||||||
None ->
|
None ->
|
||||||
print_error "No current goal" "";
|
print_error "No current goal" "";
|
||||||
@ -163,6 +165,8 @@ let rec interactive (get_instr : unit -> instr) (sl : (interactive_state) list)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
| Tact t ->
|
| Tact t ->
|
||||||
|
(* on applique la tactique et on copie l'état actuel de la preuve pour un futur Undo
|
||||||
|
Comme OCaml évalue de la droite vers la gauche, on fait bien la copie avant de modifier les références dans la preuve *)
|
||||||
(cg, (apply_tactic (g, gs) t))::(clean_state (cg, (g, gs)))::sq |> interactive get_instr
|
(cg, (apply_tactic (g, gs) t))::(clean_state (cg, (g, gs)))::sq |> interactive get_instr
|
||||||
with
|
with
|
||||||
Parser.Error ->
|
Parser.Error ->
|
||||||
@ -214,7 +218,7 @@ let recupere_entree () =
|
|||||||
else Simple begin
|
else Simple begin
|
||||||
let cmd_buff = ref [] in
|
let cmd_buff = ref [] in
|
||||||
if !nom_fichier = "" then
|
if !nom_fichier = "" then
|
||||||
(
|
((* récupérer les commandes depuis stdin, les lignes vides sont considérées comme des erreurs *)
|
||||||
fun () ->
|
fun () ->
|
||||||
match !cmd_buff with
|
match !cmd_buff with
|
||||||
| [] ->
|
| [] ->
|
||||||
@ -227,7 +231,7 @@ let recupere_entree () =
|
|||||||
| e::q -> cmd_buff := q; e
|
| e::q -> cmd_buff := q; e
|
||||||
)
|
)
|
||||||
else
|
else
|
||||||
(
|
((* récupérer les commandes depuis un fichier *)
|
||||||
fun () ->
|
fun () ->
|
||||||
match !cmd_buff with
|
match !cmd_buff with
|
||||||
| [] ->
|
| [] ->
|
||||||
|
Loading…
Reference in New Issue
Block a user