The returned line number is from the beginning of the string, starting at zero. Returns an empty list if no loops found.
(astr, level)
| 101 | """ |
| 102 | # Parse string for repeat loops |
| 103 | def parse_structure(astr, level): |
| 104 | """ |
| 105 | The returned line number is from the beginning of the string, starting |
| 106 | at zero. Returns an empty list if no loops found. |
| 107 | |
| 108 | """ |
| 109 | if level == 0: |
| 110 | loopbeg = "/**begin repeat" |
| 111 | loopend = "/**end repeat**/" |
| 112 | else: |
| 113 | loopbeg = f"/**begin repeat{level}" |
| 114 | loopend = f"/**end repeat{level}**/" |
| 115 | |
| 116 | ind = 0 |
| 117 | line = 0 |
| 118 | spanlist = [] |
| 119 | while True: |
| 120 | start = astr.find(loopbeg, ind) |
| 121 | if start == -1: |
| 122 | break |
| 123 | start2 = astr.find("*/", start) |
| 124 | start2 = astr.find("\n", start2) |
| 125 | fini1 = astr.find(loopend, start2) |
| 126 | fini2 = astr.find("\n", fini1) |
| 127 | line += astr.count("\n", ind, start2 + 1) |
| 128 | spanlist.append((start, start2 + 1, fini1, fini2 + 1, line)) |
| 129 | line += astr.count("\n", start2 + 1, fini2) |
| 130 | ind = fini2 |
| 131 | spanlist.sort() |
| 132 | return spanlist |
| 133 | |
| 134 | |
| 135 | def paren_repl(obj): |
no test coverage detected
searching dependent graphs…