diff options
author | Pascal Rigaux <pixel@mandriva.com> | 2003-10-01 09:43:15 +0000 |
---|---|---|
committer | Pascal Rigaux <pixel@mandriva.com> | 2003-10-01 09:43:15 +0000 |
commit | 2f9ebebdd8225291f814c3d8ae65c677e804fad5 (patch) | |
tree | 03c74fe65e70685836fc3deddb8838eb74d1a7dd /perl_checker.src/lexer.mll | |
parent | dc1e0c5271eb328d543755e0683f07cfc2104f36 (diff) | |
download | perl-MDK-Common-2f9ebebdd8225291f814c3d8ae65c677e804fad5.tar perl-MDK-Common-2f9ebebdd8225291f814c3d8ae65c677e804fad5.tar.gz perl-MDK-Common-2f9ebebdd8225291f814c3d8ae65c677e804fad5.tar.bz2 perl-MDK-Common-2f9ebebdd8225291f814c3d8ae65c677e804fad5.tar.xz perl-MDK-Common-2f9ebebdd8225291f814c3d8ae65c677e804fad5.zip |
make the difference between N("xxx") and "xxx"
so that we can say: replace "xxx\"xxx" with qq(xxx"xxx)
Diffstat (limited to 'perl_checker.src/lexer.mll')
-rw-r--r-- | perl_checker.src/lexer.mll | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/perl_checker.src/lexer.mll b/perl_checker.src/lexer.mll index 6703aaf..526843f 100644 --- a/perl_checker.src/lexer.mll +++ b/perl_checker.src/lexer.mll @@ -236,6 +236,7 @@ type string_escape_kinds = Double_quote | Qq | Delimited | Here_doc let string_escape_kind = ref Double_quote let not_ok_for_match = ref (-1) let string_nestness = ref 0 +let string_is_i18n = ref false let building_current_interpolated_string = Stack.create() let building_current_string = Stack.create() @@ -273,6 +274,7 @@ let raw_ins_to_string t lexbuf = RAW_STRING(s, pos) let ins_to_string t lexbuf = let s, pos = ins t lexbuf in + string_is_i18n := false ; not_ok_for_match := lexeme_end lexbuf; STRING(s, pos) @@ -682,6 +684,8 @@ rule token = parse INT(lexeme lexbuf, pos lexbuf) } +| 'N' '_'? "(\"" { string_is_i18n := true ; putback lexbuf 2 ; BAREWORD(lexeme lexbuf, pos lexbuf) } + | '"' { ins_to_string string lexbuf } | "'" { raw_ins_to_string rawstring lexbuf } | '`' { delimit_char := '`'; @@ -818,11 +822,10 @@ and string_escape = parse let c = lexeme lexbuf in (match !string_escape_kind with | Double_quote -> - if c = "\"" then - (* don't warn since it's used a lot, esp. in N("xxx \"xxx\" xxx") *) - (*warn lexbuf "you can replace \"xxx\\\"xxx\" with qq(xxx\"xxx), that way you don't need to escape <\">"*) - () - else warn_escape_unneeded lexbuf c + if c <> "\"" then + warn_escape_unneeded lexbuf c + else if not !string_is_i18n then + warn lexbuf "you can replace \"xxx\\\"xxx\" with qq(xxx\"xxx), that way you don't need to escape <\">" | Qq -> if c <> "(" && c <> ")" then warn_escape_unneeded lexbuf c | Here_doc -> warn_escape_unneeded lexbuf c | Delimited -> if c = String.make 1 !delimit_char then |