MCPcopy Index your code
hub / github.com/python/cpython / match_paren

Function match_paren

Tools/c-analyzer/c_parser/parser/_common.py:66–78  ·  view source on GitHub ↗
(text, depth=0)

Source from the content-addressed store, hash-verified

64
65
66def match_paren(text, depth=0):
67 pos = 0
68 while (m := _PAREN_RE.match(text, pos)):
69 pos = m.end()
70 _open, _close = m.groups()
71 if _open:
72 depth += 1
73 else: # _close
74 depth -= 1
75 if depth == 0:
76 return pos
77 else:
78 raise ValueError(f'could not find matching parens for {text!r}')
79
80
81VAR_DECL = set_capture_groups(_VAR_DECL, (

Callers 1

parse_function_bodyFunction · 0.85

Calls 3

matchMethod · 0.45
endMethod · 0.45
groupsMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…