Skip to content

Commit

Permalink
Merge pull request #29 from OCamlPro/2015-10-29-demo
Browse files Browse the repository at this point in the history
2015 10 29 demo
  • Loading branch information
lefessan committed Oct 29, 2015
2 parents 6cbd50e + 0c7dc3a commit 178f3a2
Show file tree
Hide file tree
Showing 33 changed files with 275 additions and 182 deletions.
7 changes: 4 additions & 3 deletions build.ocp
Expand Up @@ -91,11 +91,11 @@ end

begin program "scilint"
dirname += [ "src/scilint" ]
files = [
files = [
"scilabUtils.ml"
"scilintProject.ml"
"scilintPassExpandEval.ml"
"scilabFiveFunctionAnalyze.ml"
"scilintPassExpandEval.ml"
"scilintMain.ml"
]

Expand Down Expand Up @@ -123,7 +123,8 @@ begin program "scilob"
requires = [
"scilab_parser"
"unix"
"re.pcre"
"re.pcre"
"archimedes"
]
end

Expand Down
6 changes: 3 additions & 3 deletions share/arguments.scilint
Expand Up @@ -7,7 +7,7 @@ addf:2:TOOMANY
addhistory:1:TOOMANY
addinter:1:STRING
addinter:3:TOOMANY
amell:1:SCALAR
#amell:1:SCALAR
amell:2:TOOMANY
and:2:TOOMANY
argn:0:INTENUM:0:2
Expand All @@ -18,8 +18,8 @@ atan:2:TOOMANY:1:2
backslash:2:TOOMANY:2:2
balanc:2:TOOMANY:2:2
basename:3:TOOMANY:1:3
basename:1:BOOL
basename:2:BOOL
#basename:1:BOOL
#basename:2:BOOL
besselh:4:TOOMANY:2:4
besseli:3:TOOMANY:2:3
besseli:3:INT
Expand Down
64 changes: 35 additions & 29 deletions src/common/scilintManual.ml
Expand Up @@ -382,9 +382,9 @@ let style_warnings_info =
]

let style_warnings = [
601, "Function names should start with lowercase", [0;4], [] ;
602, "Function names should not contain digits", [0;4], [] ;
603, "Inconsistent string delimiters", [0;4], [
001, "Function names should start with lowercase", [0;4], [] ;
002, "Function names should not contain digits", [0;4], [] ;
003, "Inconsistent string delimiters", [0;4], [
PAR [
S "A string starting with a " ;
SCODE "\"" ;
Expand All @@ -402,7 +402,7 @@ let style_warnings = [
SCODE "\"this is a quote: ''\""
]
] ;
604, "Inconsistent matrix delimiters", [0;4], [
004, "Inconsistent matrix delimiters", [0;4], [
PAR [
S "A string starting with a " ;
SCODE "[" ;
Expand All @@ -415,7 +415,7 @@ let style_warnings = [
S ")."
]
] ;
605, "Inconsistent matrix separators", [], [
005, "Inconsistent matrix separators", [], [
PAR [
S "This warning is issued when spaces and comas are both used to \
separate the cells of a single matrix litteral which can lead to misreadings." ;
Expand All @@ -428,11 +428,11 @@ let style_warnings = [
all semicolons by line breaks."
]
] ;
606, "Spaces in operator", [0 ;4], [
006, "Spaces in operator", [0 ;4], [
PAR [ S "Scilab's interpreter accepts spaces inside some operators, such as " ;
SCODE ". * ." ; S " which is not a good idea." ]
] ;
607, "Spaces around dot", [0 ;4], [
007, "Spaces around dot", [0 ;4], [
PAR [ S "In some cases, a space before the dot of a field access gives a different \
sense to the code line. For instance, " ;
SCODE "v.f = 3" ;
Expand All @@ -442,32 +442,32 @@ let style_warnings = [
S "It is thus a good idea to avoid spaces around all dots."
]
] ;
608, "Missing function parameters", [0 ;4], [
008, "Missing function parameters", [0 ;4], [
PAR [ S "It is recommended to make explicit an empty list of arguments by writing " ;
SCODE "()" ;
S " instead of just breaking the line after the function name."
]
] ;
609, "Missing catch", [0 ;4], [
009, "Missing catch", [0 ;4], [
PAR [ S "A try block without a catch statement is probably useless." ]
] ;
610, "Misused keyword", [0 ;4], [
010, "Misused keyword", [0 ;4], [
PAR [ S "Using a language keyword as a variable, field name or anything but a keyword \
makes code difficult to read." ] ;
PAR [ S "To correct this, rename the variable." ]
] ;
611, "Keyword as shell arg", [0 ;4], [
011, "Keyword as shell arg", [0 ;4], [
PAR [ S "Using a language keyword unquoted inside a shell call such as in " ;
SCODE "disp end";
S " makes code difficult to read." ] ;
PAR [ S "To correct this, surround the keyword with quotes, such as " ;
SCODE "disp 'end'" ]
] ;
612, "Deprecated", [0 ;4], [
012, "Deprecated", [0 ;4], [
PAR [ S "This warning is issued when a deprecated function, operator or \
construct is encountered." ]
] ;
613, "Ambiguous dot at left of operator", [0 ;4], [
013, "Ambiguous dot at left of operator", [0 ;4], [
PAR [ S "This warning is issued when a sequence similar to " ;
SCODE "3./2" ;
S " is encountered, which is interpreted as " ;
Expand All @@ -477,7 +477,7 @@ let style_warnings = [
PAR [ S "To correct it, just insert a space if you meant a dotted operator \
or remove the dot otherwise." ]
] ;
614, "Ambiguous dot at right of operator", [0 ;4], [
014, "Ambiguous dot at right of operator", [0 ;4], [
PAR [ S "This warning is issued when a sequence similar to " ;
SCODE "3/.2" ;
S " is encountered, which is interpreted as " ;
Expand All @@ -493,23 +493,28 @@ let style_warnings = [
let warnings = [
"Function Warnings",
function_warnings_info,
function_warnings;
function_warnings,
'L';

"File Warnings",
file_warnings_info,
file_warnings;
file_warnings,
'F';

"Global Warnings",
global_warnings_info,
global_warnings;
global_warnings,
'G';

"Typing Warnings",
typing_warnings_info,
typing_warnings;
typing_warnings,
'T';

"Style Warnings",
style_warnings_info,
style_warnings;
style_warnings,
'S';

]

Expand Down Expand Up @@ -560,20 +565,21 @@ let changelog = [
];
];

"0.4", "Oct 29, 2015", [
(* To insert for next release:
"Warning W601: function names should start with lowercase";
"Warning W602: function names should not contain digits";
"Warning W603: Inconsistent string delimiters";
"Warning W604: Inconsistent matrix delimiters";
"Warning W606: Spaces in operator";
"Warning W607: Spaces around dot";
"Warning W608: Missing function parameters";
"Warning W609: Missing catch";
"Warning S001: function names should start with lowercase";
"Warning S002: function names should not contain digits";
"Warning S003: Inconsistent string delimiters";
"Warning S004: Inconsistent matrix delimiters";
"Warning S006: Spaces in operator";
"Warning S007: Spaces around dot";
"Warning S008: Missing function parameters";
"Warning S009: Missing catch";
"Warning W610: Misused keyword";
"Warning W611: Keyword as shell arg";
"Warning W612: Deprecated";
"Warning W613: Ambiguous dot at left of operator";
"Warning W614: Ambiguous dot at right of operator"; *)
]

]

]
48 changes: 24 additions & 24 deletions src/common/scilintWarning.ml
Expand Up @@ -129,45 +129,45 @@ and format_loc ppf ?(inline = false) loc =
let rec format_local_warning ppf descr =
match descr with
| Uninitialized_var s ->
Format.fprintf ppf "variable %s not initialized" s
Format.fprintf ppf "variable %S not initialized" s
| Unused_arg s ->
Format.fprintf ppf "variable %s not used" s
Format.fprintf ppf "variable %S not used" s
| Duplicate_arg s ->
Format.fprintf ppf "argument %s appears several times" s
Format.fprintf ppf "argument %S appears several times" s
| Duplicate_return s ->
Format.fprintf ppf "return variable %s appears several times" s
Format.fprintf ppf "return variable %S appears several times" s
| Var_arg_ret s ->
Format.fprintf ppf "return variable %s is also an argument" s
Format.fprintf ppf "return variable %S is also an argument" s
| Unset_ret s ->
Format.fprintf ppf "return variable %s is not set" s
Format.fprintf ppf "return variable %S is not set" s
| Return_as_var s ->
Format.fprintf ppf "return variable %s is used as a local variable" s
Format.fprintf ppf "return variable %S is used as a local variable" s
| For_var_modif ->
Format.fprintf ppf "modifying variable of for loop does not change loop behavior"
| Primitive_with_too_many_arguments (fun_name, i) ->
Format.fprintf ppf "primitive %s called with too many arguments (>= %d)" fun_name i
Format.fprintf ppf "primitive %S called with too many arguments (>= %d)" fun_name i
| Overriding_primitive fun_name ->
Format.fprintf ppf "overriding primitive %s" fun_name
Format.fprintf ppf "overriding primitive %S" fun_name
| Overriding_declared_function (fun_name, fun_loc) ->
Format.fprintf ppf "overriding function %s already declared at %a"
Format.fprintf ppf "overriding function %S already declared at %a"
fun_name (format_loc ~inline:true) fun_loc
| Overriding_toplevel_function (fun_name, file) ->
Format.fprintf ppf "overriding toplevel function %s of file %S" fun_name file
Format.fprintf ppf "overriding toplevel function %S of file %S" fun_name file
| Unexpected_string_argument (fun_name, i, s, possible) ->
Format.fprintf ppf "Function %s does not expect %S as argument %d. \
Should be one of: %s"
Format.fprintf ppf "Function %S does not expect %S as argument %d. \
Should be one of: %S"
fun_name s (succ i) (String.concat ", " possible)
| Unexpected_argument_type (fun_name, i, expected_type) ->
Format.fprintf ppf "Function %s expects type %s as argument %d"
Format.fprintf ppf "Function %S expects type %S as argument %d"
fun_name expected_type (succ i)
| Int_argument_out_of_range (fun_name, i, v, min, max) ->
Format.fprintf ppf "Function %s does not expect %.1f as argument %d. \
Format.fprintf ppf "Function %S does not expect %.1f as argument %d. \
Should be between %d and %d"
fun_name v (succ i) min max
| Var_def_not_used var_name ->
Format.fprintf ppf "variable %s defined but not used" var_name
Format.fprintf ppf "variable %S defined but not used" var_name
| Var_redef_not_used var_name ->
Format.fprintf ppf "variable %s redefined before being used" var_name
Format.fprintf ppf "variable %S redefined before being used" var_name
| Break_outside_loop ->
Format.fprintf ppf "break outside of loop"
| Continue_outside_loop ->
Expand Down Expand Up @@ -251,7 +251,7 @@ and format_style_warning ppf descr =
| Keyword_as_shell_arg ->
Format.fprintf ppf "keywords in shell args should be quoted"
| Deprecated arg ->
Format.fprintf ppf "deprecated %s" arg
Format.fprintf ppf "deprecated %S" arg
| Ambiguous_dot_left_of_oper ->
Format.fprintf ppf "ambiguous decimal dot before operator"
| Ambiguous_dot_right_of_oper ->
Expand All @@ -263,7 +263,7 @@ and format_style_warning ppf descr =
and format_program_warning ppf descr =
match descr with
| Variable_cleared n ->
Format.fprintf ppf "variable %s cleared" n
Format.fprintf ppf "variable %S cleared" n
| Null_result ->
Format.fprintf ppf "this expression returns a null result"
| Too_few_arguments 1 ->
Expand All @@ -287,11 +287,11 @@ and format_program_warning ppf descr =
| Unused_results nb ->
Format.fprintf ppf "%d results of this expression are ignored" nb
| Unused_argument_label n ->
Format.fprintf ppf "argument name %s unused" n
Format.fprintf ppf "argument name %S unused" n
| Duplicate_argument_label lbl ->
Format.fprintf ppf "argument name %s provided twice" lbl
Format.fprintf ppf "argument name %S provided twice" lbl
| Unbound_argument_label lbl ->
Format.fprintf ppf "argument name %s unknown to the function" lbl
Format.fprintf ppf "argument name %S unknown to the function" lbl

(** Builds a displayable version of a location *)
let string_of_loc loc =
Expand Down Expand Up @@ -402,7 +402,7 @@ let format_messages format messages ppf =
List.iter (fun (n, v) -> Format.fprintf ppf " %s=%S" n v)
in
let markup n a c =
let c ppf () = c ppf in
let c ppf () = c ppf in
Format.fprintf ppf "@[<hv 2><%s%a>@,%a@;<0 -2>@]</%s>" n attrs a c () n
and ocmarkup n a =
Format.fprintf ppf "<%s%a/>" n attrs a
Expand Down Expand Up @@ -507,7 +507,7 @@ let format_messages format messages ppf =
markup "results" [] (fun _ ->
let rec sep = function
| [] -> ()
| [ m ] -> message m
| [ m ] -> message m
| m :: ms -> message m ; br () ; sep ms
in
sep messages))) ;
Expand Down

0 comments on commit 178f3a2

Please sign in to comment.