MCPcopy Create free account
hub / github.com/dlclark/regexp2 / parseRustRegexStringAt

Function parseRustRegexStringAt

regexp_corpus_rust_test.go:312–345  ·  view source on GitHub ↗
(t *testing.T, raw string, start int)

Source from the content-addressed store, hash-verified

310}
311
312func parseRustRegexStringAt(t *testing.T, raw string, start int) (string, int) {
313 t.Helper()
314 if strings.HasPrefix(raw[start:], "'''") {
315 end := strings.Index(raw[start+3:], "'''")
316 if end < 0 {
317 t.Fatalf("unterminated TOML literal string %q", raw[start:])
318 }
319 return raw[start+3 : start+3+end], start + 3 + end + 3
320 }
321 if raw[start] == '\'' {
322 end := strings.IndexByte(raw[start+1:], '\'')
323 if end < 0 {
324 t.Fatalf("unterminated TOML literal string %q", raw[start:])
325 }
326 return raw[start+1 : start+1+end], start + 1 + end + 1
327 }
328 if raw[start] == '"' {
329 for end := start + 1; end < len(raw); end++ {
330 if raw[end] == '\\' {
331 end++
332 continue
333 }
334 if raw[end] == '"' {
335 s, err := strconv.Unquote(raw[start : end+1])
336 if err != nil {
337 t.Fatalf("invalid TOML basic string %q: %v", raw[start:end+1], err)
338 }
339 return s, end + 1
340 }
341 }
342 }
343 t.Fatalf("expected TOML string at %q", raw[start:])
344 return "", 0
345}
346
347func parseRustRegexMatches(t *testing.T, raw string) []rustRegexMatch {
348 t.Helper()

Callers 2

parseRustRegexStringFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected