summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPascal Rigaux <pixel@mandriva.com>2004-10-13 02:32:33 +0000
committerPascal Rigaux <pixel@mandriva.com>2004-10-13 02:32:33 +0000
commit0c86ac32772aa6ae9733f834e639fe1997c24168 (patch)
treedb10bcde4c7cefcf8d180fcd80ec4ac1e83d711b
parent7e9dccd02cd694632fdbcd0b7f0c524aa95b6fe2 (diff)
downloadperl_checker-0c86ac32772aa6ae9733f834e639fe1997c24168.tar
perl_checker-0c86ac32772aa6ae9733f834e639fe1997c24168.tar.gz
perl_checker-0c86ac32772aa6ae9733f834e639fe1997c24168.tar.bz2
perl_checker-0c86ac32772aa6ae9733f834e639fe1997c24168.tar.xz
perl_checker-0c86ac32772aa6ae9733f834e639fe1997c24168.zip
handle "use Gtk2 -init"
-rw-r--r--perl_checker.src/parser.mly8
-rw-r--r--perl_checker.src/test/syntax_restrictions.t2
2 files changed, 8 insertions, 2 deletions
diff --git a/perl_checker.src/parser.mly b/perl_checker.src/parser.mly
index f988523..4b3f70c 100644
--- a/perl_checker.src/parser.mly
+++ b/perl_checker.src/parser.mly
@@ -258,7 +258,6 @@ term:
| term QUESTION_MARK BRACKET expr BRACKET_END COLON term {sp_p($2); sp_p($3); sp_p($4); sp_p($5); sp_p($6); sp_p($7); mcontext_check M_bool $1; to_Call_op_ (mcontext_merge $7.mcontext (M_ref M_hash)) P_ternary "?:" (check_ternary_paras(prio_lo P_ternary $1, hash_ref $4, prio_lo_after P_ternary $7)) $1 $7}
| term QUESTION_MARK BRACKET expr BRACKET_END COLON BRACKET expr BRACKET_END {sp_p($2); sp_p($3); sp_p($4); sp_p($5); sp_p($6); sp_p($7); sp_p($8); sp_p($9); mcontext_check M_bool $1; to_Call_op_ (M_ref M_hash) P_ternary "?:" (check_ternary_paras(prio_lo P_ternary $1, hash_ref $4, hash_ref $8)) $1 $9}
-
/* Unary operators and terms */
| PLUS term %prec UNARY_MINUS {
sp_0($2);
@@ -267,7 +266,12 @@ term:
warn_rule "don't use unary +" ;
to_Call_op_ (mcontext_float_or_int [$2.mcontext]) P_tight "+ unary" [$2.any.expr] $1 $2
| "-" ->
- to_Call_op_ (mcontext_float_or_int [$2.mcontext]) P_tight "- unary" [$2.any.expr] $1 $2
+ (match $2.any.expr with
+ | Ident(_, _, pos) when $2.spaces = Space_0 ->
+ let s = "-" ^ string_of_Ident $2.any.expr in
+ warn_rule (Printf.sprintf "don't use %s, use '%s' instead" s s);
+ new_pesp M_string P_tok (Raw_string(s, pos)) $1 $2
+ | _ -> to_Call_op_ (mcontext_float_or_int [$2.mcontext]) P_tight "- unary" [$2.any.expr] $1 $2)
| _ -> die_rule "syntax error"
}
| TIGHT_NOT term {check_negatable_expr $2; mcontext_check M_bool $2; to_Call_op_ M_bool P_tight "not" [$2.any.expr] $1 $2}
diff --git a/perl_checker.src/test/syntax_restrictions.t b/perl_checker.src/test/syntax_restrictions.t
index ee5437b..19e2aa9 100644
--- a/perl_checker.src/test/syntax_restrictions.t
+++ b/perl_checker.src/test/syntax_restrictions.t
@@ -8,6 +8,8 @@ qw/a b c/ don't use qw/.../, use qw(...) instead
qx(xxx) don't use qx{...}, use `...` instead
+-xxx don't use -xxx, use '-xxx' instead
+
not $xxx don't use "not", use "!" instead
$1 =~ /xxx/ do not use the result of a match (eg: $1) to match another pattern