aboutsummaryrefslogtreecommitdiffstats
path: root/cparser/Parse.ml
diff options
context:
space:
mode:
authorBernhard Schommer <bschommer@users.noreply.github.com>2018-02-08 16:38:54 +0100
committerXavier Leroy <xavierleroy@users.noreply.github.com>2018-02-08 16:38:54 +0100
commitf02f00a01b598567f70e138c144d9581973802e6 (patch)
treedb15b2ad60692f936435cdd784e7bb7f6a977a40 /cparser/Parse.ml
parent54fa98c3833091a75d0c1afe84b42afc35452fe3 (diff)
downloadcompcert-kvx-f02f00a01b598567f70e138c144d9581973802e6.tar.gz
compcert-kvx-f02f00a01b598567f70e138c144d9581973802e6.zip
Refactor the handling of errors and warnings (#44)
* Module Cerrors is now called Diagnostic and can be used in parts of CompCert other than cparser/ * Replaced eprintf error. Instead of having eprintf msg; exit 2 use the functions from the Diagnostics module. * Raise on error before calling external tools. * Added diagnostics to clightgen. * Fix error handling of AsmToJson. * Cleanup error handling of Elab and C2C. *The implementation of location printing (file & line) is simplified and correctly prints valid filenames with invalid lines.
Diffstat (limited to 'cparser/Parse.ml')
-rw-r--r--cparser/Parse.ml15
1 files changed, 6 insertions, 9 deletions
diff --git a/cparser/Parse.ml b/cparser/Parse.ml
index ecd13332..8665e158 100644
--- a/cparser/Parse.ml
+++ b/cparser/Parse.ml
@@ -46,7 +46,7 @@ let read_file sourcefile =
text
let preprocessed_file transfs name sourcefile =
- Cerrors.reset();
+ Diagnostics.reset();
(* Reading the whole file at once may seem costly, but seems to be
the simplest / most robust way of accessing the text underlying
a range of positions. This is used when printing an error message.
@@ -55,7 +55,6 @@ let preprocessed_file transfs name sourcefile =
on my machine. *)
let text = read_file sourcefile in
let p =
- try
let t = parse_transformations transfs in
let rec inf = Datatypes.S inf in
let ast : Cabs.definition list =
@@ -70,13 +69,11 @@ let preprocessed_file transfs name sourcefile =
| Parser.Parser.Inter.Fail_pr ->
(* Theoretically impossible : implies inconsistencies
between grammars. *)
- Cerrors.fatal_error Cutil.no_loc "Internal error while parsing"
+ Diagnostics.fatal_error Diagnostics.no_loc "Internal error while parsing"
| Parser.Parser.Inter.Timeout_pr -> assert false
| Parser.Parser.Inter.Parsed_pr (ast, _ ) -> ast) in
let p1 = Timing.time "Elaboration" Elab.elab_file ast in
- Cerrors.raise_on_errors ();
- Timing.time2 "Emulations" transform_program t p1 name
- with
- | Cerrors.Abort ->
- [] in
- if Cerrors.check_errors() then None else Some p
+ Diagnostics.check_errors ();
+ Timing.time2 "Emulations" transform_program t p1 name in
+ Diagnostics.check_errors();
+ p