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

Function parse_double_quoted_string

nodedb-sql/src/parser/object_literal.rs:131–166  ·  view source on GitHub ↗
(chars: &[char], pos: &mut usize)

Source from the content-addressed store, hash-verified

129}
130
131fn parse_double_quoted_string(chars: &[char], pos: &mut usize) -> Result<String, SqlError> {
132 if *pos >= chars.len() || chars[*pos] != '"' {
133 return Err(SqlError::Parse {
134 detail: format!(
135 "expected double quote at position {}, found {:?}",
136 pos,
137 chars.get(*pos)
138 ),
139 });
140 }
141 *pos += 1;
142 let mut s = String::new();
143 loop {
144 if *pos >= chars.len() {
145 return Err(SqlError::Parse {
146 detail: "unterminated double-quoted string literal".to_string(),
147 });
148 }
149 match chars[*pos] {
150 '"' => {
151 *pos += 1;
152 if *pos < chars.len() && chars[*pos] == '"' {
153 s.push('"');
154 *pos += 1;
155 } else {
156 break;
157 }
158 }
159 c => {
160 s.push(c);
161 *pos += 1;
162 }
163 }
164 }
165 Ok(s)
166}
167
168fn parse_number(chars: &[char], pos: &mut usize) -> Result<Value, SqlError> {
169 let start = *pos;

Callers 1

parse_objectFunction · 0.85

Calls 3

to_stringMethod · 0.80
lenMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected