MCPcopy Create free account
hub / github.com/OpenPTrack/open_ptrack_v2 / FindEndOfExpressionInLine

Function FindEndOfExpressionInLine

rtpose_wrapper/scripts/cpp_lint.py:1230–1251  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

1228
1229
1230def 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
1254def CloseExpression(clean_lines, linenum, pos):

Callers 2

CloseExpressionFunction · 0.85
CheckCheckFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected