From a4f140b0f3fa0e1fcedb2c8472e5bb6cbf051684 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Wed, 22 Aug 2018 13:22:06 +0300 Subject: no escape --- crates/libsyntax2/src/lexer/strings.rs | 45 ++++++++++++++++++++++------------ 1 file changed, 29 insertions(+), 16 deletions(-) (limited to 'crates/libsyntax2/src/lexer') 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, c2: Option { + ptr.bump(); + if ptr.next_is('\\') || ptr.next_is('\'') { + ptr.bump(); + } + } + '\'' => { + ptr.bump(); + return; + } + '\n' => return, + _ => { ptr.bump(); } - continue; - } - if ptr.next_is('\'') { - ptr.bump(); - return; - } - if ptr.next_is('\n') { - break; } - ptr.bump(); } } @@ -56,9 +57,21 @@ pub(crate) fn scan_byte_char_or_string(ptr: &mut Ptr) -> SyntaxKind { } pub(crate) fn scan_string(ptr: &mut Ptr) { - while let Some(c) = ptr.bump() { - if c == '"' { - return; + while let Some(c) = ptr.next() { + match c { + '\\' => { + ptr.bump(); + if ptr.next_is('\\') || ptr.next_is('"') { + ptr.bump(); + } + } + '"' => { + ptr.bump(); + return; + } + _ => { + ptr.bump(); + }, } } } -- cgit v1.2.3