From f02f00a01b598567f70e138c144d9581973802e6 Mon Sep 17 00:00:00 2001 From: Bernhard Schommer Date: Thu, 8 Feb 2018 16:38:54 +0100 Subject: 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. --- driver/Commandline.mli | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'driver/Commandline.mli') diff --git a/driver/Commandline.mli b/driver/Commandline.mli index 32f5daf3..e1b917f2 100644 --- a/driver/Commandline.mli +++ b/driver/Commandline.mli @@ -35,12 +35,17 @@ type action = | Integer of (int -> unit) (** read next arg as an int, call function *) | Ignore (** ignore the next arg *) | Unit of (unit -> unit) (** call the function with unit as argument *) - -val parse_cmdline: (pattern * action) list -> unit - (* Note on precedence: [Exact] patterns are tried first, then the other patterns are tried in the order in which they appear in the list. *) +exception CmdError of string +(** Raise by [parse_cmdline] when an error occured *) + +val parse_cmdline: (pattern * action) list -> unit +(** [parse_cmdline actions] parses the commandline and performs all [actions]. + Raises [CmdError] if an error occurred. +*) + val longopt_int: string -> (int -> unit) -> pattern * action (** [longopt_int key fn] generates a pattern and an action for options of the form [key=] and calls [fn] with the integer argument -- cgit