From 1f9d32f972f018ef1a0cfabee8f146e56fc68f01 Mon Sep 17 00:00:00 2001 From: John Date: Mon, 15 Sep 2025 00:21:14 -0400 Subject: [PATCH] cl-lexer: Make strings curly-brace-aware, for future format string work --- compiler/cl-lexer/src/lib.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/compiler/cl-lexer/src/lib.rs b/compiler/cl-lexer/src/lib.rs index 355c417..d08b062 100644 --- a/compiler/cl-lexer/src/lib.rs +++ b/compiler/cl-lexer/src/lib.rs @@ -375,12 +375,21 @@ impl Lexer<'_> { /// Produces a [Literal](Kind::Literal) with a pre-escaped [String] pub fn string(&mut self) -> Result { let mut lexeme = String::new(); + let mut depth = 0; self.consume(); loop { lexeme.push(match self.take() { None => Err(self.error(Reason::UnmatchedDelimiters('"')))?, Some('\\') => self.unescape()?, - Some('"') => break, + Some('"') if depth == 0 => break, + Some(c @ '{') => { + depth += 1; + c + } + Some(c @ '}') => { + depth -= 1; + c + } Some(c) => c, }) }