aboutsummaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
Diffstat (limited to 'bin')
-rw-r--r--bin/qsp_parser.ml26
1 files changed, 19 insertions, 7 deletions
diff --git a/bin/qsp_parser.ml b/bin/qsp_parser.ml
index ffb1bd5..fb0c1c8 100644
--- a/bin/qsp_parser.ml
+++ b/bin/qsp_parser.ml
@@ -9,6 +9,7 @@ module Args = struct
let usage = "qsp_parser input_file"
let anon_fun filename = input_files := filename :: !input_files
let level_value = ref None
+ let reset_line = ref false
let level : string -> unit =
fun str_level ->
@@ -19,12 +20,18 @@ module Args = struct
exit 1
let speclist =
- [ ("--level", Arg.String level, "Message level [debug, warn, error]") ]
+ [
+ ("--level", Arg.String level, "Message level [debug, warn, error]");
+ ( "--global",
+ Arg.Set reset_line,
+ "Each line is refered from the begining of the file and not the \
+ location" );
+ ]
let parse () =
let () = Arg.parse speclist anon_fun usage in
let filters = { level = !level_value } in
- (!input_files, filters)
+ (!input_files, !reset_line, filters)
end
(** Filter the results given by the analysis *)
@@ -41,7 +48,7 @@ let filter_report : filters -> Report.t list -> Report.t -> Report.t list =
(** Read the source file until getting a report (the whole location has been
read properly), or until the first syntax error.
*)
-let parse_location : Sedlexing.lexbuf -> filters -> unit =
+let parse_location : Qparser.Lexbuf.t -> filters -> unit =
fun lexbuf filters ->
let result = Qparser.Analyzer.parse (module Qsp_syntax.Type_of) lexbuf in
@@ -56,17 +63,17 @@ let parse_location : Sedlexing.lexbuf -> filters -> unit =
match report with
| [] -> ()
| _ ->
- let start_position, _ = Sedlexing.lexing_positions lexbuf in
+ let start_position, _ = Qparser.Lexbuf.positions lexbuf in
Format.fprintf Format.std_formatter "Location %s@;@[%a@]@."
start_position.Lexing.pos_fname pp_result report;
())
| Error e ->
- let start_position, _ = Sedlexing.lexing_positions lexbuf in
+ let start_position, _ = Qparser.Lexbuf.positions lexbuf in
Format.fprintf Format.std_formatter "Location %s@;@[%a]@."
start_position.Lexing.pos_fname Report.pp e
let () =
- let file_names, filters = Args.parse () in
+ let file_names, reset_line, filters = Args.parse () in
let file_name = List.hd file_names in
let ic = Stdlib.open_in_bin file_name in
@@ -78,6 +85,7 @@ let () =
| ".txt" -> Sedlexing.Utf16.from_channel ic (Some Little_endian)
| _ -> raise (Failure "unknown extension")
in
+ let lexer = Qparser.Lexbuf.from_lexbuf ~reset_line lexer in
let () =
try
@@ -87,6 +95,10 @@ let () =
with Qparser.Lexer.EOF -> ()
in
let () =
- match Sys.os_type with "Win32" -> ignore @@ read_line () | _ -> ()
+ match Sys.os_type with
+ | "Win32" ->
+ print_endline "Press <Enter> to terminate";
+ ignore @@ read_line ()
+ | _ -> ()
in
()