Commit a610b3f7 authored by David Hauzar's avatar David Hauzar

Merge branch 'counter-examples'

parents aff46e8d d92706f7
......@@ -289,13 +289,22 @@ let interleave_with_source
~filename
~source_code =
try
let model_file = StringMap.find filename model.model_files in
let lines = Str.split (Str.regexp "^") source_code in
let model_file = StringMap.find filename model.model_files in
let src_lines_up_to_last_cntexmp_el source_code model_file =
let (last_cntexmp_line, _) = IntMap.max_binding model_file in
let lines = Str.bounded_split (Str.regexp "^") source_code (last_cntexmp_line+1) in
let remove_last_element list =
let list_rev = List.rev list in
match list_rev with
| _ :: tail -> List.rev tail
| _ -> List.rev list_rev
in
remove_last_element lines in
let (source_code, _) = List.fold_left
(interleave_line
start_comment end_comment me_name_trans model_file)
("", 1)
lines in
(src_lines_up_to_last_cntexmp_el source_code model_file) in
source_code
with Not_found ->
source_code
......
......@@ -33,6 +33,9 @@ let () = reset_gc ()
let debug = Debug.lookup_flag "ide_info"
let debug_show_text_cntexmp = Debug.register_info_flag "show_text_cntexmp"
~desc:"Print@ textual@ counterexample@ before@ printing@ counterexample@ interleaved@ with@ cource@ code."
(************************)
(* parsing command line *)
(************************)
......@@ -644,13 +647,19 @@ let update_tabs a =
match a.S.proof_state with
| S.Done r ->
if not (Model_parser.is_model_empty r.Call_provers.pr_model) then begin
"Counterexample:\n" ^
(Model_parser.model_to_string r.Call_provers.pr_model) ^
"\n\nSource code interleaved with counterexample:" ^
let cntexample_text =
if Debug.test_flag debug_show_text_cntexmp then
"Counterexample:\n" ^
(Model_parser.model_to_string r.Call_provers.pr_model) ^
"\n\nSource code interleaved with counterexample:"
else
"" in
let cntexample_text = cntexample_text ^
(Model_parser.interleave_with_source
r.Call_provers.pr_model
~filename:!current_file
~source_code:(Sysutil.file_contents !current_file))
~source_code:(Sysutil.file_contents !current_file)) in
cntexample_text
end else
""
| _ -> ""
......@@ -671,6 +680,7 @@ let update_tabs a =
edited_view#scroll_to_mark `INSERT;
output_view#source_buffer#set_text output_text;
counterexample_view#source_buffer#set_text counterexample_text;
counterexample_view#scroll_to_mark `INSERT;
......
......@@ -194,16 +194,27 @@ let () = Trans.register_transform "intro_vc_vars_counterexmp"
intro_vc_vars_counterexmp
~desc:"Introduce."
let rec string_join sep l =
match l with
| [] -> ""
| [x] -> x
| x :: rest -> x ^ sep ^ string_join sep rest
let get_location_of_vc task =
let meta_args = Task.on_meta_excl meta_vc_location task in
match meta_args with
| Some [Theory.MAstr loc_str] ->
let splitted = Strings.bounded_split ':' loc_str 4 in
let loc = match splitted with
| [filename; line; col1; col2] ->
(* There may be colons in the file name. We still split on the colon, look at
the last three elements, and put the remaining ones back together to form the
file name. We may lose colons at the beginning or end of the filename, but
even on windows that's not allowed. *)
let split = Strings.rev_split ':' loc_str in
let loc = match split with
| col2 :: col1 :: line :: ((_ :: _) as rest) ->
let line = int_of_string line in
let col1 = int_of_string col1 in
let col2 = int_of_string col2 in
let filename = string_join ":" (List.rev rest) in
Some (Loc.user_position filename line col1 col2)
| _ -> None in
loc
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment