From fb14c7c26586056d9958c32c9728c5de01608702 Mon Sep 17 00:00:00 2001 From: Dmitry Shirshov Date: Sun, 15 Dec 2024 21:25:24 +0300 Subject: [PATCH] fix(whitespaces): do not strip whitespaces when removing previous token --- src/parser.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/parser.rs b/src/parser.rs index 25638dc..f5a6125 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -136,7 +136,7 @@ impl Parser { return result; } let mut tokens = vec![Token::new(lexem, std::mem::take(&mut self.whitespace))]; - while let Some(token) = tokens.pop() { + while let Some(mut token) = tokens.pop() { match validate( self.states.last().cloned().unwrap_or_default(), token.lexem.clone(), @@ -164,8 +164,9 @@ impl Parser { Validate::DropBefore => { self.states.pop(); if let Some(t) = std::mem::take(&mut self.delay) { - self.whitespace = t.whitespace_before + &self.whitespace; + token.whitespace_before = t.whitespace_before + &token.whitespace_before; } + tokens.push(token); continue; } };