summaryrefslogtreecommitdiffstats
path: root/perl_checker.src
diff options
context:
space:
mode:
authorPascal Rigaux <pixel@mandriva.com>2003-04-01 12:41:54 +0000
committerPascal Rigaux <pixel@mandriva.com>2003-04-01 12:41:54 +0000
commitd31b53ad935ef10af26d9d176d776dc0578a357c (patch)
tree9c01f51aa7608bfea70008951b43c21ae56bce33 /perl_checker.src
parentb3b01cb33e788ca7d87593072e8cd4824d08e362 (diff)
downloadperl_checker-d31b53ad935ef10af26d9d176d776dc0578a357c.tar
perl_checker-d31b53ad935ef10af26d9d176d776dc0578a357c.tar.gz
perl_checker-d31b53ad935ef10af26d9d176d776dc0578a357c.tar.bz2
perl_checker-d31b53ad935ef10af26d9d176d776dc0578a357c.tar.xz
perl_checker-d31b53ad935ef10af26d9d176d776dc0578a357c.zip
- make "please don't use prototype pre-declaration" a warning
- make a warning for unary plus instead of a "syntax error"
Diffstat (limited to 'perl_checker.src')
-rw-r--r--perl_checker.src/parser.mly13
1 files changed, 11 insertions, 2 deletions
diff --git a/perl_checker.src/parser.mly b/perl_checker.src/parser.mly
index d499285..4d73fca 100644
--- a/perl_checker.src/parser.mly
+++ b/perl_checker.src/parser.mly
@@ -153,7 +153,7 @@ sideff: /* An expression which may have a side-effect */
decl:
| FORMAT BAREWORD ASSIGN {Too_complex, sp_pos_range $1 $3}
| FORMAT ASSIGN {Too_complex, sp_pos_range $1 $2}
-| func_decl semi_colon {die_rule (if sndfst $1 = "" then "there is no need to pre-declare in Perl!" else "please don't use prototype pre-declaration") }
+| func_decl semi_colon {if sndfst $1 = "" then die_rule "there is no need to pre-declare in Perl!" else (warn_rule "please don't use prototype pre-declaration" ; Too_complex, sp_pos_range $1 $2) }
| func_decl BRACKET BRACKET_END {sp_n($2); sp_0_or_cr($3); let name, proto = fst $1 in sub_declaration (name, proto) [], sp_pos_range $1 $3}
| func_decl BRACKET lines BRACKET_END {sp_n($2); check_block_sub $3 $4; sub_declaration (fst $1) (fst $3), sp_pos_range $1 $4}
| func_decl BRACKET BRACKET expr BRACKET_END BRACKET_END {sp_n($2); sp_p($3); sp_p($4); sp_p($5); sp_p($6); sub_declaration (fst $1) [Ref(I_hash, prio_lo P_loose $4)], sp_pos_range $1 $6}
@@ -243,7 +243,16 @@ term:
/* Unary operators and terms */
-| PLUS term %prec UNARY_MINUS {if fst $1 <> "-" then die_rule "syntax error"; sp_0($2); to_Call_op_(P_tight, "- unary", [sndfst $2]) (sp_pos_range $1 $2)}
+| PLUS term %prec UNARY_MINUS {
+ sp_0($2);
+ match fst $1 with
+ | "+" ->
+ warn_rule "don't use unary +" ;
+ to_Call_op_(P_tight, "+ unary", [sndfst $2]) (sp_pos_range $1 $2)
+ | "-" ->
+ to_Call_op_(P_tight, "- unary", [sndfst $2]) (sp_pos_range $1 $2)
+ | _ -> die_rule "syntax error"
+}
| TIGHT_NOT term {to_Call_op_(P_tight, "not", [sndfst $2]) (sp_pos_range $1 $2)}
| BIT_NEG term {to_Call_op_(P_expr, "~", [sndfst $2]) (sp_pos_range $1 $2)}
| INCR term {sp_0($2); to_Call_op_(P_tight, "++", [sndfst $2]) (sp_pos_range $1 $2)}