From 6e4573f9a1ace7cba38d0cecb95b4dfe95c73c71 Mon Sep 17 00:00:00 2001 From: Alasdair Armstrong Date: Fri, 6 Oct 2017 16:53:15 +0100 Subject: Various improvements to menhir parser, and performance improvments for Z3 calls New option -memo_z3 memoizes calls to the Z3 solver, and saves these results between calls to sail. This greatly increases the performance of sail when re-checking large specifications by about an order of magnitude. For example: time sail -no_effects prelude.sail aarch64_no_vector.sail real 0m4.391s user 0m0.856s sys 0m0.464s After running with -memo_z3 once, running again gives: time sail -memo_z3 -no_effects prelude.sail aarch64_no_vector.sail real 0m0.457s user 0m0.448s sys 0m0.008s Both the old and the new parser should now have better error messages where the location of the parse error is displayed visually in the error message and highlighted. --- src/reporting_basic.ml | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'src/reporting_basic.ml') diff --git a/src/reporting_basic.ml b/src/reporting_basic.ml index e552dca4..a47ee8ae 100644 --- a/src/reporting_basic.ml +++ b/src/reporting_basic.ml @@ -87,14 +87,6 @@ (* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *) (**************************************************************************) -let format_pos ff p = - let open Lexing in - begin - Format.fprintf ff "file \"%s\", line %d, character %d:\n" - p.pos_fname p.pos_lnum (p.pos_cnum - p.pos_bol); - Format.pp_print_flush ff () - end - let rec skip_lines in_chan = function | n when n <= 0 -> () | n -> input_line in_chan; skip_lines in_chan (n - 1) @@ -126,6 +118,16 @@ let print_code1 ff fname lnum1 cnum1 cnum2 = end with _ -> () +let format_pos ff p = + let open Lexing in + begin + Format.fprintf ff "file \"%s\", line %d, character %d:\n\n" + p.pos_fname p.pos_lnum (p.pos_cnum - p.pos_bol); + print_code1 ff p.pos_fname p.pos_lnum (p.pos_cnum - p.pos_bol) (p.pos_cnum - p.pos_bol + 1); + Format.fprintf ff "\n\n"; + Format.pp_print_flush ff () + end + let print_code2 ff fname lnum1 cnum1 lnum2 cnum2 = try let in_chan = open_in fname in -- cgit v1.2.3