summaryrefslogtreecommitdiffstats
path: root/perl_checker.src
diff options
context:
space:
mode:
authorPascal Rigaux <pixel@mandriva.com>2003-12-15 15:35:23 +0000
committerPascal Rigaux <pixel@mandriva.com>2003-12-15 15:35:23 +0000
commitd585bff07cf831f557cb5bca530fe9a539ad72b5 (patch)
treea408d590fe93b4d6299ead13a4d9ab37770eaef9 /perl_checker.src
parent4dbce6d83dbfd9ebefed80f9b735ad2a3359172c (diff)
downloadperl_checker-d585bff07cf831f557cb5bca530fe9a539ad72b5.tar
perl_checker-d585bff07cf831f557cb5bca530fe9a539ad72b5.tar.gz
perl_checker-d585bff07cf831f557cb5bca530fe9a539ad72b5.tar.bz2
perl_checker-d585bff07cf831f557cb5bca530fe9a539ad72b5.tar.xz
perl_checker-d585bff07cf831f557cb5bca530fe9a539ad72b5.zip
allow to specify the return context of functions instead of always saying M_unknown
Diffstat (limited to 'perl_checker.src')
-rw-r--r--perl_checker.src/parser.mly4
-rw-r--r--perl_checker.src/parser_helper.ml19
-rw-r--r--perl_checker.src/parser_helper.mli9
3 files changed, 17 insertions, 15 deletions
diff --git a/perl_checker.src/parser.mly b/perl_checker.src/parser.mly
index 82b80df..9fa0deb 100644
--- a/perl_checker.src/parser.mly
+++ b/perl_checker.src/parser.mly
@@ -319,11 +319,11 @@ term:
| ONE_SCALAR_PARA word argexpr {check_parenthesized_first_argexpr_with_Ident $2.any $3; call_one_scalar_para $1 [call(Deref(I_func, $2.any), $3.any.expr)] $1 $3} /* ref foo $a, $b */
| ONE_SCALAR_PARA hash PKG_SCOPE {sp_0($3); call_one_scalar_para $1 [ Call(Too_complex, [$2.any]) ] $1 $3} /* keys %main:: */
-| func parenthesized {sp_0($2); new_pesp M_unknown P_tok (call_func $1 $2) $1 $2} /* &foo(@args) */
+| func parenthesized {sp_0($2); call_func $1 $2} /* &foo(@args) */
| word argexpr {check_parenthesized_first_argexpr_with_Ident $1.any $2; call_no_paren $1 $2} /* foo $a, $b */
| word BRACKET lines BRACKET_END COMMA argexpr %prec LSTOP {sp_n($2); new_pesp M_unknown P_call_no_paren (call(Deref(I_func, $1.any), Ref(I_hash, List $3.any) :: $6.any.expr)) $1 $6} /* bless { foo }, $bar */
| word_paren parenthesized {sp_0($2); call_with_paren $1 $2} /* foo(@args) */
-| word BRACKET lines BRACKET_END listexpr %prec LSTOP {sp_n($2); check_block_sub $3 $4; call_and_context(Deref(I_func, $1.any), anonymous_sub None $3 :: $5.any.expr) (if $5.any.expr = [] then P_tok else P_call_no_paren) $1 $5} /* map { foo } @bar */
+| word BRACKET lines BRACKET_END listexpr %prec LSTOP {sp_n($2); check_block_sub $3 $4; call_and_context(Deref(I_func, $1.any), anonymous_sub None $3 :: $5.any.expr) false (if $5.any.expr = [] then P_tok else P_call_no_paren) $1 $5} /* map { foo } @bar */
| word BRACKET BRACKET expr BRACKET_END BRACKET_END listexpr %prec LSTOP {sp_n($2); sp_p($3); sp_p($4); sp_p($5); sp_p($6); new_pesp M_unknown (if $7.any.expr = [] then P_tok else P_call_no_paren) (call(Deref(I_func, $1.any), anonymous_sub None (new_esp (M_ref M_hash) [ Ref(I_hash, $4.any.expr) ] $4 $4) :: $7.any.expr)) $1 $7} /* map { { foo } } @bar */
| word BRACKET BRACKET expr BRACKET_END semi_colon BRACKET_END listexpr %prec LSTOP {sp_n($2); sp_p($3); sp_p($4); sp_p($5); sp_p($7); new_pesp M_unknown (if $8.any.expr = [] then P_tok else P_call_no_paren) (call(Deref(I_func, $1.any), anonymous_sub None (new_esp (M_ref M_hash) [ Ref(I_hash, $4.any.expr); Semi_colon ] $4 $4) :: $8.any.expr)) $1 $8} /* map { { foo }; } @bar */
diff --git a/perl_checker.src/parser_helper.ml b/perl_checker.src/parser_helper.ml
index a07ad38..48bb7f7 100644
--- a/perl_checker.src/parser_helper.ml
+++ b/perl_checker.src/parser_helper.ml
@@ -742,7 +742,7 @@ msgstr \"\"
) pot_strings ;
close_out fd
-let call_raw is_a_func (e, para) =
+let call_raw force_non_builtin_func (e, para) =
match e with
| Deref(I_func, Ident(None, f, _)) ->
let para' = match f with
@@ -776,7 +776,7 @@ let call_raw is_a_func (e, para) =
| [ Ident(None, s, pos) ] -> Some [ Raw_string(s, pos) ]
| _ -> None)
- | "last" | "next" | "redo" when not is_a_func ->
+ | "last" | "next" | "redo" when not force_non_builtin_func ->
(match para with
| [ Ident(None, s, pos) ] -> Some [ Raw_string(s, pos) ]
| _ -> die_rule (sprintf "%s must be used with a raw string" f))
@@ -823,18 +823,13 @@ let call_raw is_a_func (e, para) =
let call(e, para) = call_raw false (e, para)
-let call_func esp_func esp_para = call_raw true (esp_func.any, esp_para.any.expr)
-
let check_return esp_func esp_para =
match esp_func.any with
| Ident(None, "return", _) ->
prio_lo_check P_call_no_paren esp_para.any.priority esp_para.pos (List esp_para.any.expr)
| _ -> ()
-let call_no_paren esp_func esp_para = check_return esp_func esp_para; new_pesp M_unknown P_call_no_paren (call(Deref(I_func, esp_func.any), esp_para.any.expr)) esp_func esp_para
-let call_with_paren esp_func esp_para = check_return esp_func esp_para; new_pesp M_unknown P_tok (call(Deref(I_func, esp_func.any), esp_para.any.expr)) esp_func esp_para
-
-let call_and_context(e, para) priority esp_start esp_end =
+let call_and_context(e, para) force_non_builtin_func priority esp_start esp_end =
let context =
match e with
| Deref(I_func, Ident(None, f, _)) ->
@@ -847,7 +842,13 @@ let call_and_context(e, para) priority esp_start esp_end =
| _ -> M_unknown)
| _ -> M_unknown
in
- new_pesp context priority (call(e, para)) esp_start esp_end
+ new_pesp context priority (call_raw force_non_builtin_func (e, para)) esp_start esp_end
+
+let call_no_paren esp_func esp_para = check_return esp_func esp_para; call_and_context(Deref(I_func, esp_func.any), esp_para.any.expr) false P_call_no_paren esp_func esp_para
+let call_with_paren esp_func esp_para = check_return esp_func esp_para; call_and_context (Deref(I_func, esp_func.any), esp_para.any.expr) false P_tok esp_func esp_para
+
+let call_func esp_func esp_para =
+ call_and_context(esp_func.any, esp_para.any.expr) true P_tok esp_func esp_para
let call_one_scalar_para { any = e ; pos = pos } para esp_start esp_end =
let para =
diff --git a/perl_checker.src/parser_helper.mli b/perl_checker.src/parser_helper.mli
index fc27172..a97b4ed 100644
--- a/perl_checker.src/parser_helper.mli
+++ b/perl_checker.src/parser_helper.mli
@@ -187,10 +187,6 @@ val generate_pot : string -> unit
val call_raw :
bool -> Types.fromparser * Types.fromparser list -> Types.fromparser
val call : Types.fromparser * Types.fromparser list -> Types.fromparser
-val call_func :
- Types.fromparser Types.any_spaces_pos ->
- Types.fromparser list Types.prio_anyexpr Types.any_spaces_pos ->
- Types.fromparser
val check_return :
Types.fromparser Types.any_spaces_pos ->
Types.fromparser list Types.prio_anyexpr Types.any_spaces_pos -> unit
@@ -204,10 +200,15 @@ val call_with_paren :
Types.fromparser Types.prio_anyexpr Types.any_spaces_pos
val call_and_context :
Types.fromparser * Types.fromparser list ->
+ bool ->
Types.priority ->
'a Types.any_spaces_pos ->
'b Types.any_spaces_pos ->
Types.fromparser Types.prio_anyexpr Types.any_spaces_pos
+val call_func :
+ Types.fromparser Types.any_spaces_pos ->
+ Types.fromparser list Types.prio_anyexpr Types.any_spaces_pos ->
+ Types.fromparser Types.prio_anyexpr Types.any_spaces_pos
val call_one_scalar_para :
string Types.any_spaces_pos ->
Types.fromparser list ->