diff options
author | Pascal Rigaux <pixel@mandriva.com> | 2005-11-25 15:59:43 +0000 |
---|---|---|
committer | Pascal Rigaux <pixel@mandriva.com> | 2005-11-25 15:59:43 +0000 |
commit | ada42c36da4c78d96f05ef9f4ffac162b200c533 (patch) | |
tree | 44c1a901f894b180c4783b61db80309f16bf76fd | |
parent | 4e990ed92226f64ec268fe6b627ec3c72ea212bb (diff) | |
download | perl_checker-ada42c36da4c78d96f05ef9f4ffac162b200c533.tar perl_checker-ada42c36da4c78d96f05ef9f4ffac162b200c533.tar.gz perl_checker-ada42c36da4c78d96f05ef9f4ffac162b200c533.tar.bz2 perl_checker-ada42c36da4c78d96f05ef9f4ffac162b200c533.tar.xz perl_checker-ada42c36da4c78d96f05ef9f4ffac162b200c533.zip |
- make <<"EOF" a warning, not an error (and adapt test for it)
- fix warning "Trailing spaces after HERE-document mark" (was on stderr)
-rw-r--r-- | perl_checker.src/lexer.mll | 15 | ||||
-rw-r--r-- | perl_checker.src/test/syntax_restrictions.t | 2 |
2 files changed, 10 insertions, 7 deletions
diff --git a/perl_checker.src/lexer.mll b/perl_checker.src/lexer.mll index 7de0f13..389a179 100644 --- a/perl_checker.src/lexer.mll +++ b/perl_checker.src/lexer.mll @@ -677,16 +677,19 @@ rule token = parse not_ok_for_match := lexeme_end lexbuf; HERE_DOC(here_doc_next_line (skip_n_char 2 (lexeme lexbuf)), pos lexbuf) } +| "<<\"" ident "\"" { + warn_with_pos [Warn_suggest_simpler] (lexeme_start lexbuf + 2, lexeme_end lexbuf) "Don't use <<\"MARK\", use <<MARK instead" ; + not_ok_for_match := lexeme_end lexbuf; + HERE_DOC(here_doc_next_line (skip_n_char_ 3 1 (lexeme lexbuf)), pos lexbuf) + } | "<<'" ident "'" { not_ok_for_match := lexeme_end lexbuf; RAW_HERE_DOC(raw_here_doc_next_line (skip_n_char_ 3 1 (lexeme lexbuf)), pos lexbuf) } | "<<" ' '+ "'" -| "<<" ' '+ ident { - failwith (pos2sfull_with (lexeme_start lexbuf + 2) (lexeme_end lexbuf) ^ "No space allowed between \"<<\" and the marker") - } +| "<<" ' '+ ident | "<<" ' '* '"' { - failwith (pos2sfull_with (lexeme_start lexbuf + 2) (lexeme_end lexbuf) ^ "Don't use <<\"MARK\", use <<MARK instead") + failwith (pos2sfull_with (lexeme_start lexbuf + 2) (lexeme_end lexbuf) ^ "No space allowed between \"<<\" and the marker") } | "\\"+ stash @@ -880,7 +883,7 @@ and here_doc = parse let s = lexeme lexbuf in if chomps s <> !current_here_doc_mark then next_s s here_doc lexbuf - else if s <> !current_here_doc_mark then Printf.eprintf "%sTrailing spaces after HERE-document mark\n" (pos2sfull lexbuf) + else if s <> !current_here_doc_mark then warn_with_pos [Warn_traps] (pos lexbuf) "Trailing spaces after HERE-document mark" } | '\n' { add_a_new_line(lexeme_end lexbuf); @@ -893,7 +896,7 @@ and raw_here_doc = parse let s = lexeme lexbuf in if chomps s <> !current_here_doc_mark then next_s s raw_here_doc lexbuf - else if s <> !current_here_doc_mark then Printf.eprintf "%sTrailing spaces after HERE-document mark\n" (pos2sfull lexbuf) + else if s <> !current_here_doc_mark then warn_with_pos [Warn_traps] (pos lexbuf) "Trailing spaces after HERE-document mark" } | '\n' { add_a_new_line(lexeme_end lexbuf); diff --git a/perl_checker.src/test/syntax_restrictions.t b/perl_checker.src/test/syntax_restrictions.t index eb186d8..de7bf77 100644 --- a/perl_checker.src/test/syntax_restrictions.t +++ b/perl_checker.src/test/syntax_restrictions.t @@ -65,6 +65,6 @@ sub f2 { my ($x, $_y) = @_; $x } not enough parameters f2(@l); # ok f2(xxx()); # bad -<<"EOF" Don't use <<"MARK", use <<MARK instead +$xxx = <<"EOF"; Don't use <<"MARK", use <<MARK instead foo EOF |