Even better error reporting

This commit is contained in:
Dmitry Boulytchev 2020-01-11 16:38:25 +03:00
parent b6180d8634
commit 92f60665df
3 changed files with 56 additions and 44 deletions

View file

@ -109,7 +109,7 @@ class options args =
end
let main =
(* try*)
try
let cmd = new options Sys.argv in
match (try parse cmd with Language.Semantic_error msg -> `Fail msg) with
| `Ok prog ->
@ -136,6 +136,5 @@ let main =
List.iter (fun i -> Printf.printf "%d\n" i) output
)
| `Fail er -> Printf.eprintf "Error: %s\n" er
(* with Invalid_argument _ ->
Printf.printf "Usage: rc [-i | -s] <input file.expr>\n"
*)
with Language.Semantic_error msg -> Printf.printf "Error: %s\n" msg