diff options
author | Pascal Rigaux <pixel@mandriva.com> | 2004-12-05 20:28:02 +0000 |
---|---|---|
committer | Pascal Rigaux <pixel@mandriva.com> | 2004-12-05 20:28:02 +0000 |
commit | 03308c3b52cab6cafdb5584b6fa6b367b73a740f (patch) | |
tree | 37c8f8a4ddd8ac25b7ce56c22d427a4ab0d12a24 /perl_checker.src | |
parent | e7884d3a3cf3b0cc2bea836dc5040b7a157bc39d (diff) | |
download | perl-MDK-Common-03308c3b52cab6cafdb5584b6fa6b367b73a740f.tar perl-MDK-Common-03308c3b52cab6cafdb5584b6fa6b367b73a740f.tar.gz perl-MDK-Common-03308c3b52cab6cafdb5584b6fa6b367b73a740f.tar.bz2 perl-MDK-Common-03308c3b52cab6cafdb5584b6fa6b367b73a740f.tar.xz perl-MDK-Common-03308c3b52cab6cafdb5584b6fa6b367b73a740f.zip |
create to_Deref_with_arrow()
Diffstat (limited to 'perl_checker.src')
-rw-r--r-- | perl_checker.src/parser_helper.ml | 9 | ||||
-rw-r--r-- | perl_checker.src/parser_helper.mli | 8 |
2 files changed, 11 insertions, 6 deletions
diff --git a/perl_checker.src/parser_helper.ml b/perl_checker.src/parser_helper.ml index c0d27f1..731b78f 100644 --- a/perl_checker.src/parser_helper.ml +++ b/perl_checker.src/parser_helper.ml @@ -496,10 +496,9 @@ let check_hash_subscript esp = | List [Raw_string(s, _)] when can_be_raw_string s -> warn [Warn_suggest_simpler] esp.pos (sprintf "{'%s'} can be written {%s}" s s) | _ -> () -let check_arrow_needed esp1 esp2 = - match esp1.any.expr with +let check_arrow_needed arrow = function | Deref_with(I_array, I_scalar, List [List [Call _]], _) -> () (* "->" needed for (f())[0]->{XX} *) - | Deref_with _ -> warn [Warn_suggest_simpler] esp2.pos "the arrow \"->\" is unneeded" + | Deref_with _ -> warn [Warn_suggest_simpler] arrow.pos "the arrow \"->\" is unneeded" | _ -> () let check_scalar_subscripted esp = @@ -672,6 +671,10 @@ let to_Deref_with(from_context, to_context, ref_, para) = if is_not_a_scalar ref_ then warn_rule [] "bad deref"; Deref_with(from_context, to_context, ref_, para) +let to_Deref_with_arrow arrow (from_context, to_context, ref_, para) = + if from_context != I_func then check_arrow_needed arrow ref_ ; + to_Deref_with(from_context, to_context, ref_, para) + let lines_to_Block esp_lines esp_BRACKET_END = check_block_lines esp_lines esp_BRACKET_END; Block (fst esp_lines.any) diff --git a/perl_checker.src/parser_helper.mli b/perl_checker.src/parser_helper.mli index 6485011..0708792 100644 --- a/perl_checker.src/parser_helper.mli +++ b/perl_checker.src/parser_helper.mli @@ -103,9 +103,7 @@ val check_parenthesized_first_argexpr_with_Ident : Types.fromparser list Types.prio_anyexpr Types.any_spaces_pos -> unit val check_hash_subscript : Types.fromparser Types.prio_anyexpr Types.any_spaces_pos -> unit -val check_arrow_needed : - Types.fromparser Types.prio_anyexpr Types.any_spaces_pos -> - 'a Types.any_spaces_pos -> unit +val check_arrow_needed : 'a Types.any_spaces_pos -> Types.fromparser -> unit val check_scalar_subscripted : Types.fromparser Types.any_spaces_pos -> unit val negatable_ops : (string * string) list val check_negatable_expr : @@ -158,6 +156,10 @@ val to_Method_call : val to_Deref_with : Types.context * Types.context * Types.fromparser * Types.fromparser -> Types.fromparser +val to_Deref_with_arrow : + 'a Types.any_spaces_pos -> + Types.context * Types.context * Types.fromparser * Types.fromparser -> + Types.fromparser val lines_to_Block : (Types.fromparser list * bool) Types.any_spaces_pos -> 'a Types.any_spaces_pos -> Types.fromparser |