From 14f99f8633e4c7f984f7a490780353c9c7c12a92 Mon Sep 17 00:00:00 2001 From: ahabhgk Date: Mon, 11 Nov 2024 14:38:20 +0800 Subject: [PATCH] fix --- src/lexer.rs | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/src/lexer.rs b/src/lexer.rs index 9cd6948..b444164 100644 --- a/src/lexer.rs +++ b/src/lexer.rs @@ -348,28 +348,24 @@ impl<'s> Lexer<'s> { pub fn consume_string>(&mut self, visitor: &mut T, end: char) -> Option<()> { let start = self.cur_pos()?; self.consume(); - 'outer: loop { + loop { let c = self.cur()?; if c == end { self.consume(); break; - } - if is_new_line(c) { + } else if is_new_line(c) { break; - } - while self.cur()? == C_REVERSE_SOLIDUS { + } else if c == C_REVERSE_SOLIDUS { self.consume(); - if is_new_line(self.cur()?) { + let c2 = self.cur()?; + if is_new_line(c2) { self.consume(); - } else { + } else if are_valid_escape(c, c2) { self.consume_escaped()?; - if self.cur()? == end { - self.consume(); - break 'outer; - } } + } else { + self.consume(); } - self.consume(); } visitor.string(self, start, self.cur_pos()?) }