MCPcopy Create free account
hub / github.com/numpy/numpy / parse_structure

Function parse_structure

numpy/f2py/_src_pyf.py:54–79  ·  view source on GitHub ↗

Return a list of tuples for each function or subroutine each tuple is the start and end of a subroutine or function to be expanded.

(astr)

Source from the content-addressed store, hash-verified

52function_start_re = re.compile(r'\n (\$|\*)\s*function\b', re.I)
53
54def parse_structure(astr):
55 """ Return a list of tuples for each function or subroutine each
56 tuple is the start and end of a subroutine or function to be
57 expanded.
58 """
59
60 spanlist = []
61 ind = 0
62 while True:
63 m = routine_start_re.search(astr, ind)
64 if m is None:
65 break
66 start = m.start()
67 if function_start_re.match(astr, start, m.end()):
68 while True:
69 i = astr.rfind('\n', ind, start)
70 if i==-1:
71 break
72 start = i
73 if astr[i:i+7]!='\n $':
74 break
75 start += 1
76 m = routine_end_re.search(astr, m.end())
77 ind = end = m and m.end()-1 or len(astr)
78 spanlist.append((start, end))
79 return spanlist
80
81template_re = re.compile(r"<\s*(\w[\w\d]*)\s*>")
82named_re = re.compile(r"<\s*(\w[\w\d]*)\s*=\s*(.*?)\s*>")

Callers 1

process_strFunction · 0.70

Calls 1

rfindMethod · 0.80

Tested by

no test coverage detected