MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / consume_object

Function consume_object

nodedb-sql/src/ddl_ast/graph_parse/tokenizer.rs:67–99  ·  view source on GitHub ↗
(sql: &'a str, bytes: &[u8], start: usize, out: &mut Vec<Tok<'a>>)

Source from the content-addressed store, hash-verified

65}
66
67fn 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
101fn consume_word<'a>(sql: &'a str, bytes: &[u8], start: usize, out: &mut Vec<Tok<'a>>) -> usize {
102 let mut j = start;

Callers 1

tokenizeFunction · 0.85

Calls 2

lenMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected