From 109658332a75ca91d6dc2bf573e0ab77fa5619ca Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Tue, 14 Aug 2018 15:03:27 +0300 Subject: Support raw strings in lexer --- crates/libsyntax2/src/lexer/strings.rs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'crates/libsyntax2/src/lexer') diff --git a/crates/libsyntax2/src/lexer/strings.rs b/crates/libsyntax2/src/lexer/strings.rs index e3704fbb3..fbae767e5 100644 --- a/crates/libsyntax2/src/lexer/strings.rs +++ b/crates/libsyntax2/src/lexer/strings.rs @@ -55,6 +55,11 @@ pub(crate) fn scan_string(ptr: &mut Ptr) { } pub(crate) fn scan_raw_string(ptr: &mut Ptr) { + let mut hashes = 0; + while ptr.next_is('#') { + hashes += 1; + ptr.bump(); + } if !ptr.next_is('"') { return; } @@ -62,7 +67,14 @@ pub(crate) fn scan_raw_string(ptr: &mut Ptr) { while let Some(c) = ptr.bump() { if c == '"' { - return; + let mut hashes_left = hashes; + while ptr.next_is('#') && hashes_left > 0{ + hashes_left -= 1; + ptr.bump(); + } + if hashes_left == 0 { + return; + } } } } -- cgit v1.2.3