MCPcopy Create free account
hub / github.com/cel-rust/cel-rust / parse_raw_string

Function parse_raw_string

cel/src/parser/parse.rs:188–248  ·  view source on GitHub ↗
(
    chars: &mut Enumerate<Chars>,
    mut res: String,
)

Source from the content-addressed store, hash-verified

186}
187
188fn parse_raw_string(
189 chars: &mut Enumerate<Chars>,
190 mut res: String,
191) -> Result<String, ParseSequenceError> {
192 let mut in_single_quotes = false;
193 let mut in_double_quotes = false;
194
195 while let Some((_, c)) = chars.next() {
196 let in_quotes = in_single_quotes || in_double_quotes;
197
198 if c == '\\' && in_quotes {
199 match chars.next() {
200 Some((_, c2)) => {
201 match c2 {
202 '"' => {
203 if in_single_quotes {
204 res.push(c);
205 }
206 }
207 '\'' => {
208 if in_double_quotes {
209 res.push(c);
210 }
211 }
212 _ => {
213 res.push(c);
214 }
215 };
216 res.push(c2);
217 continue;
218 }
219 _ => {
220 res.push(c);
221 continue;
222 }
223 };
224 } else if c == '\'' {
225 if in_double_quotes {
226 res.push(c);
227 continue;
228 }
229
230 in_single_quotes = !in_single_quotes;
231 continue;
232 } else if c == '"' {
233 if in_single_quotes {
234 res.push(c);
235 continue;
236 }
237
238 in_double_quotes = !in_double_quotes;
239 continue;
240 } else if !in_quotes {
241 return Err(ParseSequenceError::MissingOpeningQuote);
242 }
243
244 res.push(c);
245 }

Callers 1

parse_stringFunction · 0.85

Calls 2

pushMethod · 0.80
nextMethod · 0.45

Tested by

no test coverage detected