summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPascal Rigaux <pixel@mandriva.com>2004-08-12 01:22:33 +0000
committerPascal Rigaux <pixel@mandriva.com>2004-08-12 01:22:33 +0000
commit93961da97bea62cd585fc4ae690431ce740dadba (patch)
tree3e1a2e72eaa48d30143a8b01ffb11a996f4e9bd0
parent7952c6294c573fcd9328399b08d6d79dd28e605d (diff)
downloadperl_checker-93961da97bea62cd585fc4ae690431ce740dadba.tar
perl_checker-93961da97bea62cd585fc4ae690431ce740dadba.tar.gz
perl_checker-93961da97bea62cd585fc4ae690431ce740dadba.tar.bz2
perl_checker-93961da97bea62cd585fc4ae690431ce740dadba.tar.xz
perl_checker-93961da97bea62cd585fc4ae690431ce740dadba.zip
handle s:xxx:yyy: and qw/.../, issuing a warning
(hopefully the ':' added in pattern_separator won't break other lex rules...)
-rw-r--r--perl_checker.src/lexer.mll11
-rw-r--r--perl_checker.src/test/syntax_restrictions.t4
2 files changed, 14 insertions, 1 deletions
diff --git a/perl_checker.src/lexer.mll b/perl_checker.src/lexer.mll
index cf93ee7..10c3dc7 100644
--- a/perl_checker.src/lexer.mll
+++ b/perl_checker.src/lexer.mll
@@ -399,13 +399,14 @@ let hex_in_string lexbuf next_rule s =
let set_delimit_char lexbuf op =
match lexeme_char lexbuf (String.length op) with
| '@' -> die lexbuf ("don't use " ^ op ^ "@...@, replace @ with / ! , or |")
+ | ':' -> die lexbuf ("don't use " ^ op ^ ":...:, replace : with / ! , or |")
| c -> delimit_char := c
}
let stash = [ '$' '@' '%' '&' '*' ]
let ident_start = ['a'-'z' 'A'-'Z' '_']
let ident = ident_start ['0'-'9' 'A'-'Z' 'a'-'z' '_'] *
-let pattern_separator = [ '/' '!' ',' '|' '@' ]
+let pattern_separator = [ '/' '!' ',' '|' '@' ':' ]
let in_string_expr = (ident | (ident? ("::" ident)+)) "->"? (('{' [^ '{' '}' '\n']* '}') | ('[' [^ '[' ']' '\n']* ']'))*
@@ -606,6 +607,14 @@ rule token = parse
QR_PATTERN(s, opts, pos)
}
+| "qw" pattern_separator {
+ set_delimit_char lexbuf "qw" ;
+ current_string_start_line := !current_file_current_line;
+ let s, pos = raw_ins delimited_string lexbuf in
+ warn_with_pos pos (Printf.sprintf "don't use qw%c...%c, use qw(...) instead" !delimit_char !delimit_char) ;
+ QUOTEWORDS(s, pos)
+}
+
| "s" pattern_separator {
set_delimit_char lexbuf "s" ;
current_string_start_line := !current_file_current_line;
diff --git a/perl_checker.src/test/syntax_restrictions.t b/perl_checker.src/test/syntax_restrictions.t
index 27172fb..ee5437b 100644
--- a/perl_checker.src/test/syntax_restrictions.t
+++ b/perl_checker.src/test/syntax_restrictions.t
@@ -2,6 +2,10 @@ $xxx <<= 2 don't use "<<=", use the expanded versi
m@xxx@ don't use m@...@, replace @ with / ! , or |
+s:xxx:yyy: don't use s:...:, replace : with / ! , or |
+
+qw/a b c/ don't use qw/.../, use qw(...) instead
+
qx(xxx) don't use qx{...}, use `...` instead
not $xxx don't use "not", use "!" instead