diff --git a/main.ml b/main.ml index f875cfd..4ecec9b 100644 --- a/main.ml +++ b/main.ml @@ -54,23 +54,31 @@ let rec interactive ((g, gs) : proof) : proof = | Some g' -> print_goal g' in - match parse_cmd (Lexing.from_string ((read_line ())^"\n")) with - Goal ty -> fresh_proof ty |> interactive - | Tact t -> - begin match t with - Exact_term e -> - tact_exact_term (g, gs) e |> interactive - | Exact_proof s -> - tact_exact_proof (g, gs) s |> interactive - | Assumption -> - tact_assumption (g, gs) |> interactive - | Intro -> - tact_intro (g, gs) |> interactive - | Cut ty -> - tact_cut (g, gs) ty |> interactive - | Apply id -> - tact_apply (g, gs) id |> interactive - end + try + match parse_cmd (Lexing.from_string ((read_line ())^"\n")) with + Goal ty -> fresh_proof ty |> interactive + | Tact t -> + begin match t with + Exact_term e -> + tact_exact_term (g, gs) e |> interactive + | Exact_proof s -> + tact_exact_proof (g, gs) s |> interactive + | Assumption -> + tact_assumption (g, gs) |> interactive + | Intro -> + tact_intro (g, gs) |> interactive + | Cut ty -> + tact_cut (g, gs) ty |> interactive + | Apply id -> + 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 let interpret e =