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