Allow escaping of curly braces in string literals.
@@ -1532,6 +1532,8 @@ impl<'input> Lexer<'input> {
Some((_, '\'')) => Ok(Some('\'')),
Some((_, '"')) => Ok(Some('"')),
Some((_, '\\')) => Ok(Some('\\')),
+ Some((_, '{')) => Ok(Some('{')),
+ Some((_, '}')) => Ok(Some('}')),
Some((_, '/')) => Ok(Some('/')),
Some((_, 'b')) => Ok(Some('\u{8}')), // Backspace
Some((_, 'f')) => Ok(Some('\u{c}')), // Form Feed
@@ -2430,6 +2432,18 @@ mod tests {
r#" ~~ "# => Token::StringLiteral("\"".into()),
r#" ~ "# => Token::DQuote,
};
+ lex_ok! {
+ r#" "\{" "#,
+ r#" ~ "# => Token::DQuote,
+ r#" ~~ "# => Token::StringLiteral("{".into()),
+ r#" ~ "# => Token::DQuote,
+ };
+ lex_ok! {
+ r#" "\}" "#,
+ r#" ~ "# => Token::DQuote,
+ r#" ~~ "# => Token::StringLiteral("}".into()),
+ r#" ~ "# => Token::DQuote,
+ };
lex_ok! {
r#" "\"\"" "#,
