Function
consume_object
(sql: &'a str, bytes: &[u8], start: usize, out: &mut Vec<Tok<'a>>)
Source from the content-addressed store, hash-verified
| 65 | } |
| 66 | |
| 67 | fn consume_object<'a>(sql: &'a str, bytes: &[u8], start: usize, out: &mut Vec<Tok<'a>>) -> usize { |
| 68 | let mut depth = 0i32; |
| 69 | let mut j = start; |
| 70 | let mut in_quote = false; |
| 71 | while j < bytes.len() { |
| 72 | let c = bytes[j]; |
| 73 | if in_quote { |
| 74 | if c == b'\'' { |
| 75 | if j + 1 < bytes.len() && bytes[j + 1] == b'\'' { |
| 76 | j += 2; |
| 77 | continue; |
| 78 | } |
| 79 | in_quote = false; |
| 80 | } |
| 81 | } else { |
| 82 | match c { |
| 83 | b'\'' => in_quote = true, |
| 84 | b'{' => depth += 1, |
| 85 | b'}' => { |
| 86 | depth -= 1; |
| 87 | if depth == 0 { |
| 88 | j += 1; |
| 89 | break; |
| 90 | } |
| 91 | } |
| 92 | _ => {} |
| 93 | } |
| 94 | } |
| 95 | j += 1; |
| 96 | } |
| 97 | out.push(Tok::Object(&sql[start..j])); |
| 98 | j |
| 99 | } |
| 100 | |
| 101 | fn consume_word<'a>(sql: &'a str, bytes: &[u8], start: usize, out: &mut Vec<Tok<'a>>) -> usize { |
| 102 | let mut j = start; |
Tested by
no test coverage detected