strip camlp4 error messages

Ignore-this: d9cee7dccc2270054156437b92e5e57e

darcs-hash:20120222162516-c41ad-b97dd13591562c7fdb96ede631b501f4d392e32b
This commit is contained in:
Jeremie Dimino 2012-02-22 17:25:16 +01:00
parent 4171f877a6
commit f819014eb9
1 changed files with 10 additions and 1 deletions

View File

@ -55,7 +55,16 @@ let parse_toplevel_phrase_camlp4 str eos_is_error =
| exn ->
([], exn)
in
UTop.Error (locs, UTop.get_message print_camlp4_error exn)
let msg = UTop.get_message print_camlp4_error exn in
(* Camlp4 sometimes generate several empty lines at the end... *)
let idx = ref (String.length msg - 1) in
while !idx > 0 && msg.[!idx] = '\n' do
decr idx
done;
if !idx + 1 < String.length msg then
UTop.Error (locs, String.sub msg 0 (!idx + 1))
else
UTop.Error (locs, msg)
let parse_toplevel_phrase str eos_is_error =
match parse_toplevel_phrase_camlp4 str eos_is_error with