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: Index just after e
(line, startpos, depth, startchar, endchar)
| 1029 | |
| 1030 | |
| 1031 | def FindEndOfExpressionInLine(line, startpos, depth, startchar, endchar): |
| 1032 | """Find the position just after the matching endchar. |
| 1033 | |
| 1034 | Args: |
| 1035 | line: a CleansedLines line. |
| 1036 | startpos: start searching at this position. |
| 1037 | depth: nesting level at startpos. |
| 1038 | startchar: expression opening character. |
| 1039 | endchar: expression closing character. |
| 1040 | |
| 1041 | Returns: |
| 1042 | Index just after endchar. |
| 1043 | """ |
| 1044 | for i in xrange(startpos, len(line)): |
| 1045 | if line[i] == startchar: |
| 1046 | depth += 1 |
| 1047 | elif line[i] == endchar: |
| 1048 | depth -= 1 |
| 1049 | if depth == 0: |
| 1050 | return i + 1 |
| 1051 | return -1 |
| 1052 | |
| 1053 | |
| 1054 | def CloseExpression(clean_lines, linenum, pos): |