gracefully ignore invalid input

This commit is contained in:
augustin64 2024-05-01 10:35:12 +02:00
parent 486a788757
commit 7c4def6e1e

42
main.ml
View File

@ -54,23 +54,31 @@ let rec interactive ((g, gs) : proof) : proof =
| Some g' -> print_goal g' | Some g' -> print_goal g'
in in
match parse_cmd (Lexing.from_string ((read_line ())^"\n")) with try
Goal ty -> fresh_proof ty |> interactive match parse_cmd (Lexing.from_string ((read_line ())^"\n")) with
| Tact t -> Goal ty -> fresh_proof ty |> interactive
begin match t with | Tact t ->
Exact_term e -> begin match t with
tact_exact_term (g, gs) e |> interactive Exact_term e ->
| Exact_proof s -> tact_exact_term (g, gs) e |> interactive
tact_exact_proof (g, gs) s |> interactive | Exact_proof s ->
| Assumption -> tact_exact_proof (g, gs) s |> interactive
tact_assumption (g, gs) |> interactive | Assumption ->
| Intro -> tact_assumption (g, gs) |> interactive
tact_intro (g, gs) |> interactive | Intro ->
| Cut ty -> tact_intro (g, gs) |> interactive
tact_cut (g, gs) ty |> interactive | Cut ty ->
| Apply id -> tact_cut (g, gs) ty |> interactive
tact_apply (g, gs) id |> interactive | Apply id ->
end tact_apply (g, gs) id |> interactive
end
with
Parser.Error ->
print_string "Invalid input.\n";
interactive (g, gs)
| End_of_file ->
print_string "Bye!\n";
(g, gs)
end end
let interpret e = let interpret e =