diff options
author | Aleksey Kladov <[email protected]> | 2018-08-22 11:22:06 +0100 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2018-08-22 11:22:06 +0100 |
commit | a4f140b0f3fa0e1fcedb2c8472e5bb6cbf051684 (patch) | |
tree | 10e5a08a721a4d9716d518e87b360179202efc92 /crates/libsyntax2/src/lexer/strings.rs | |
parent | e8dfb92641f64b772204d7670c7286cb9b8b398b (diff) |
no escape
Diffstat (limited to 'crates/libsyntax2/src/lexer/strings.rs')
-rw-r--r-- | crates/libsyntax2/src/lexer/strings.rs | 45 |
1 files changed, 29 insertions, 16 deletions
diff --git a/crates/libsyntax2/src/lexer/strings.rs b/crates/libsyntax2/src/lexer/strings.rs index 795ea97b7..a6da97d47 100644 --- a/crates/libsyntax2/src/lexer/strings.rs +++ b/crates/libsyntax2/src/lexer/strings.rs | |||
@@ -15,22 +15,23 @@ pub(crate) fn is_string_literal_start(c: char, c1: Option<char>, c2: Option<char | |||
15 | } | 15 | } |
16 | 16 | ||
17 | pub(crate) fn scan_char(ptr: &mut Ptr) { | 17 | pub(crate) fn scan_char(ptr: &mut Ptr) { |
18 | loop { | 18 | while let Some(c) = ptr.next() { |
19 | if ptr.next_is('\\') { | 19 | match c { |
20 | ptr.bump(); | 20 | '\\' => { |
21 | if ptr.next_is('\\') || ptr.next_is('\'') { | 21 | ptr.bump(); |
22 | if ptr.next_is('\\') || ptr.next_is('\'') { | ||
23 | ptr.bump(); | ||
24 | } | ||
25 | } | ||
26 | '\'' => { | ||
27 | ptr.bump(); | ||
28 | return; | ||
29 | } | ||
30 | '\n' => return, | ||
31 | _ => { | ||
22 | ptr.bump(); | 32 | ptr.bump(); |
23 | } | 33 | } |
24 | continue; | ||
25 | } | ||
26 | if ptr.next_is('\'') { | ||
27 | ptr.bump(); | ||
28 | return; | ||
29 | } | ||
30 | if ptr.next_is('\n') { | ||
31 | break; | ||
32 | } | 34 | } |
33 | ptr.bump(); | ||
34 | } | 35 | } |
35 | } | 36 | } |
36 | 37 | ||
@@ -56,9 +57,21 @@ pub(crate) fn scan_byte_char_or_string(ptr: &mut Ptr) -> SyntaxKind { | |||
56 | } | 57 | } |
57 | 58 | ||
58 | pub(crate) fn scan_string(ptr: &mut Ptr) { | 59 | pub(crate) fn scan_string(ptr: &mut Ptr) { |
59 | while let Some(c) = ptr.bump() { | 60 | while let Some(c) = ptr.next() { |
60 | if c == '"' { | 61 | match c { |
61 | return; | 62 | '\\' => { |
63 | ptr.bump(); | ||
64 | if ptr.next_is('\\') || ptr.next_is('"') { | ||
65 | ptr.bump(); | ||
66 | } | ||
67 | } | ||
68 | '"' => { | ||
69 | ptr.bump(); | ||
70 | return; | ||
71 | } | ||
72 | _ => { | ||
73 | ptr.bump(); | ||
74 | }, | ||
62 | } | 75 | } |
63 | } | 76 | } |
64 | } | 77 | } |