Find the position just after the matching endchar. Args: line: a CleansedLines line. startpos: start searching at this position. depth: nesting level at startpos. startchar: expression opening character. endchar: expression closing character. Returns: On finding matchin
(line, startpos, depth, startchar, endchar)
| 1228 | |
| 1229 | |
| 1230 | def FindEndOfExpressionInLine(line, startpos, depth, startchar, endchar): |
| 1231 | """Find the position just after the matching endchar. |
| 1232 | |
| 1233 | Args: |
| 1234 | line: a CleansedLines line. |
| 1235 | startpos: start searching at this position. |
| 1236 | depth: nesting level at startpos. |
| 1237 | startchar: expression opening character. |
| 1238 | endchar: expression closing character. |
| 1239 | |
| 1240 | Returns: |
| 1241 | On finding matching endchar: (index just after matching endchar, 0) |
| 1242 | Otherwise: (-1, new depth at end of this line) |
| 1243 | """ |
| 1244 | for i in xrange(startpos, len(line)): |
| 1245 | if line[i] == startchar: |
| 1246 | depth += 1 |
| 1247 | elif line[i] == endchar: |
| 1248 | depth -= 1 |
| 1249 | if depth == 0: |
| 1250 | return (i + 1, 0) |
| 1251 | return (-1, depth) |
| 1252 | |
| 1253 | |
| 1254 | def CloseExpression(clean_lines, linenum, pos): |
no outgoing calls
no test coverage detected