(buf: &mut LexBuf<'a>)
| 1217 | } |
| 1218 | |
| 1219 | fn lex_embedded_element<'a>(buf: &mut LexBuf<'a>) -> Result<Cow<'a, str>, String> { |
| 1220 | let pos = buf.pos(); |
| 1221 | assert!(matches!(buf.next(), Some('{'))); |
| 1222 | let mut depth = 1; |
| 1223 | let mut in_escape = false; |
| 1224 | while depth > 0 { |
| 1225 | match buf.next() { |
| 1226 | Some('\\') => { |
| 1227 | buf.next(); // Next character is escaped, so ignore it |
| 1228 | } |
| 1229 | Some('"') => in_escape = !in_escape, // Begin or end escape |
| 1230 | Some('{') if !in_escape => depth += 1, |
| 1231 | Some('}') if !in_escape => depth -= 1, |
| 1232 | Some(_) => (), |
| 1233 | None => bail!("unterminated embedded element"), |
| 1234 | } |
| 1235 | } |
| 1236 | let s = &buf.inner()[pos..buf.pos()]; |
| 1237 | Ok(Cow::Borrowed(s)) |
| 1238 | } |
| 1239 | |
| 1240 | // Result of `None` indicates element is NULL. |
| 1241 | fn lex_unquoted_element<'a>( |
no test coverage detected