From e6b5004af0960958aab6cbdc9f24a06f00d104eb Mon Sep 17 00:00:00 2001 From: Xavier Leroy Date: Tue, 30 Dec 2014 12:54:43 +0100 Subject: Improve printing of errors. --- cparser/Env.ml | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'cparser/Env.ml') diff --git a/cparser/Env.ml b/cparser/Env.ml index 355a9960..6610c159 100644 --- a/cparser/Env.ml +++ b/cparser/Env.ml @@ -266,16 +266,24 @@ let add_enum env id info = open Printf +let composite_tag_name name = + if name = "" then "" else name + let error_message = function | Unbound_identifier name -> sprintf "Unbound identifier '%s'" name | Unbound_tag(name, kind) -> - sprintf "Unbound %s '%s'" kind name + sprintf "Unbound %s '%s'" kind (composite_tag_name name) | Tag_mismatch(name, expected, actual) -> sprintf "'%s' was declared as a %s but is used as a %s" - name actual expected + (composite_tag_name name) actual expected | Unbound_typedef name -> sprintf "Unbound typedef '%s'" name | No_member(compname, compkind, memname) -> sprintf "%s '%s' has no member named '%s'" - compkind compname memname + compkind (composite_tag_name compname) memname + +let _ = + Printexc.register_printer + (function Error e -> Some (sprintf "Env.Error \"%s\"" (error_message e)) + | _ -> None) -- cgit