aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bin/args.ml12
-rw-r--r--bin/qsp_parser.ml14
-rw-r--r--readme.md18
3 files changed, 26 insertions, 18 deletions
diff --git a/bin/args.ml b/bin/args.ml
index a98981c..54751c8 100644
--- a/bin/args.ml
+++ b/bin/args.ml
@@ -40,9 +40,7 @@ let enable_module modules identifier =
let (module C : Qsp_syntax.S.Analyzer) = Qsp_syntax.Check.get_module t in
if String.equal C.identifier identifier then C.active := true)
-let speclist modules printer =
- ignore modules;
-
+let speclist printer =
let common_arguments =
[
( "--version",
@@ -64,7 +62,7 @@ let speclist modules printer =
Arg.Set reset_line,
"\tEach line is refered from the begining of the file and not the \
location" );
- ("-<test>", Arg.String anon_fun, "\tDisable this test");
+ ("-<test>", Arg.Unit (fun () -> ()), "\tDisable this test");
("+<test>", Arg.Unit (fun () -> ()), "\tEnable this test");
]
and windows_arguments =
@@ -80,13 +78,17 @@ let parse :
list_tests:(Format.formatter -> unit) ->
string list * t =
fun ~modules ~list_tests ->
- let speclist = speclist modules list_tests in
+ let speclist = speclist list_tests in
let speclist =
let r = ref speclist in
for i = 1 to pred (Array.length Sys.argv) do
let s = Sys.argv.(i) in
if
s.[0] = '-'
+ && String.length s > 1
+ && s.[1] != '-'
+ && (not (String.equal s "--help"))
+ && (not (String.equal s "-help"))
&& not (List.exists !r ~f:(fun (s', _, _) -> String.equal s s'))
then
r :=
diff --git a/bin/qsp_parser.ml b/bin/qsp_parser.ml
index 1b2b90c..70f474e 100644
--- a/bin/qsp_parser.ml
+++ b/bin/qsp_parser.ml
@@ -48,7 +48,7 @@ let pp_modules formatter =
(* Print the name, left justified, with enought spaces for the all the
identifiers *)
- Format.fprintf formatter "%-*s" (max_length + 1) "Name";
+ Format.fprintf formatter "%-*s" (succ max_length) "Name";
(* Tab delimiter *)
Format.pp_set_tab formatter ();
Format.fprintf formatter "Active ";
@@ -65,6 +65,10 @@ let pp_modules formatter =
Format.pp_close_tbox formatter ();
Format.pp_print_break formatter 0 0
+(** Get all the tests to apply.
+
+ The expression is declared lazy in order to be sure to apply the filters
+ from the command line before. *)
let checkers : (module Qsp_syntax.S.Analyzer) Lazy.t =
lazy
(let module Check = Qsp_syntax.Check.Make (struct
@@ -102,14 +106,14 @@ let parse_location : ctx:ctx -> Qparser.Lexbuf.t -> Args.filters -> ctx =
List.fold_left report ~init:ctx ~f:(fun ctx report ->
match report.Report.level with
- | Error -> { ctx with error_nb = ctx.error_nb + 1 }
- | Warn -> { ctx with warn_nb = ctx.warn_nb + 1 }
- | Debug -> { ctx with debug_nb = ctx.debug_nb + 1 }))
+ | Error -> { ctx with error_nb = succ ctx.error_nb }
+ | Warn -> { ctx with warn_nb = succ ctx.warn_nb }
+ | Debug -> { ctx with debug_nb = succ ctx.debug_nb }))
| Error e ->
let start_position, _ = Qparser.Lexbuf.positions lexbuf in
Format.fprintf Format.std_formatter "Location@ %s@;@[%a]@."
start_position.Lexing.pos_fname Report.pp e;
- { ctx with error_nb = ctx.error_nb + 1 }
+ { ctx with error_nb = succ ctx.error_nb }
let default_ctx = { error_nb = 0; warn_nb = 0; debug_nb = 0 }
diff --git a/readme.md b/readme.md
index b125676..d18b371 100644
--- a/readme.md
+++ b/readme.md
@@ -9,13 +9,15 @@ a grammar to represent each instruction.
## Command line
- qsp_parser.exe input_file
- --version Display the version of the application and exit
- --level Message level [debug, warn, error]
- --global Each line is refered from the begining of the file and not the
- location
- -help Display this list of options
- --help Display this list of options
+ qsp_parser.exe input_file
+ --version Display the version of the application and exit
+ --list-tests Print all the available tests then exit
+ --level Filter with this message level [debug, warn, error]
+ --global Each line is refered from the begining of the file and not the location
+ -<test> Disable this test
+ +<test> Enable this test
+ -help Display this list of options
+ --help Display this list of options Display this list of options
You can run the application by giving in argument the file to analyze: the
@@ -70,7 +72,7 @@ can easily spot when a string value is used instead of a numeric.
By analysing the branchs, the application can spot the block where no `gt`
instructions are given, which can lead to dead end in the code.
-### Nested string
+### Escaped string
The application will report text strings containing only one expression with a
`debug` message.