(s, start)
| 105 | |
| 106 | // Walk from `start` forward, return index of the matching `)`. -1 if not found. |
| 107 | function _findMatchingParen(s, start) { |
| 108 | let depth = 1; |
| 109 | let i = start; |
| 110 | while (i < s.length) { |
| 111 | const c = s[i]; |
| 112 | if (c === "'" || c === '"') { |
| 113 | i = _skipString(s, i); |
| 114 | if (i === -1) return -1; |
| 115 | continue; |
| 116 | } |
| 117 | if (c === '(' || c === '[' || c === '{') depth++; |
| 118 | else if (c === ')' || c === ']' || c === '}') { |
| 119 | depth--; |
| 120 | if (depth === 0 && c === ')') return i; |
| 121 | } |
| 122 | i++; |
| 123 | } |
| 124 | return -1; |
| 125 | } |
| 126 | |
| 127 | // Skip a Python-style string starting at `s[start]` (single or double quote). |
| 128 | // Returns index just past the closing quote, or -1 on EOF. |
no test coverage detected