summaryrefslogtreecommitdiff
path: root/src/reporting_basic.ml
diff options
context:
space:
mode:
authorAlasdair Armstrong2018-03-14 19:28:14 +0000
committerAlasdair Armstrong2018-03-14 19:36:42 +0000
commite99f9e060575930bac00240f252bf6f975a13deb (patch)
tree7c1d95e55905d4a989eebc43aaff9a41099c300c /src/reporting_basic.ml
parent7aef4970c36b45f50dc61d66353dc759b438e706 (diff)
WIP Latex formatting
Added option -latex that outputs input to a latex document. Added doc comments that can be attached to certain AST nodes - right now just valspecs and function clauses, e.g. /*! Documentation for main */ val main : unit -> unit These comments are kept by the sail pretty printer, and used when generating latex
Diffstat (limited to 'src/reporting_basic.ml')
-rw-r--r--src/reporting_basic.ml23
1 files changed, 9 insertions, 14 deletions
diff --git a/src/reporting_basic.ml b/src/reporting_basic.ml
index 1fc4fc6c..65acd4ac 100644
--- a/src/reporting_basic.ml
+++ b/src/reporting_basic.ml
@@ -115,11 +115,9 @@ let print_code1 ff fname lnum1 cnum1 cnum2 =
try
skip_lines in_chan (lnum1 - 1);
let line = input_line in_chan in
- Format.fprintf ff "%s%s%s%s%s"
+ Format.fprintf ff "%s%s%s"
(Str.string_before line cnum1)
- (termcode 41)
- (Str.string_before (Str.string_after line cnum1) (cnum2 - cnum1))
- (termcode 49)
+ Util.(Str.string_before (Str.string_after line cnum1) (cnum2 - cnum1) |> red_bg |> clear)
(Str.string_after line cnum2);
close_in in_chan
with e -> (close_in_noerr in_chan; print_endline (Printexc.to_string e))
@@ -143,18 +141,14 @@ let print_code2 ff fname lnum1 cnum1 lnum2 cnum2 =
try
skip_lines in_chan (lnum1 - 1);
let line = input_line in_chan in
- Format.fprintf ff "%s%s%s%s\n"
+ Format.fprintf ff "%s%s\n"
(Str.string_before line cnum1)
- (termcode 41)
- (Str.string_after line cnum1)
- (termcode 49);
+ Util.(Str.string_after line cnum1 |> red_bg |> clear);
let lines = read_lines in_chan (lnum2 - lnum1 - 1) in
- List.iter (fun l -> Format.fprintf ff "%s%s%s\n" (termcode 41) l (termcode 49)) lines;
+ List.iter (fun l -> Format.fprintf ff "%s\n" Util.(l |> red_bg |> clear)) lines;
let line = input_line in_chan in
- Format.fprintf ff "%s%s%s%s"
- (termcode 41)
- (Str.string_before line cnum2)
- (termcode 49)
+ Format.fprintf ff "%s%s"
+ Util.(Str.string_before line cnum2 |> red_bg |> clear)
(Str.string_after line cnum2);
close_in in_chan
with e -> (close_in_noerr in_chan; print_endline (Printexc.to_string e))
@@ -205,9 +199,10 @@ let rec format_loc_aux ff l =
let (l_org, mod_s) = dest_loc l in
let _ = match l_org with
| Parse_ast.Unknown -> Format.fprintf ff "no location information available"
- | Parse_ast.Generated l -> Format.fprintf ff "Code generated: original nearby source is "; (format_loc_aux ff l)
+ | Parse_ast.Generated l -> Format.fprintf ff "code generated: original nearby source is "; (format_loc_aux ff l)
| Parse_ast.Range(p1,p2) -> format_pos2 ff p1 p2
| Parse_ast.Int(s,_) -> Format.fprintf ff "code in lib from: %s" s
+ | Parse_ast.Documented(_, l) -> format_loc_aux ff l
in
()