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

Function FindStartOfExpressionInLine

rtpose_wrapper/scripts/cpp_lint.py:1300–1324  ·  view source on GitHub ↗

Find position at the matching startchar. This is almost the reverse of FindEndOfExpressionInLine, but note that the input position and returned position differs by 1. Args: line: a CleansedLines line. endpos: start searching at this position. depth: nesting level at endpos. s

(line, endpos, depth, startchar, endchar)

Source from the content-addressed store, hash-verified

1298
1299
1300def FindStartOfExpressionInLine(line, endpos, depth, startchar, endchar):
1301 """Find position at the matching startchar.
1302
1303 This is almost the reverse of FindEndOfExpressionInLine, but note
1304 that the input position and returned position differs by 1.
1305
1306 Args:
1307 line: a CleansedLines line.
1308 endpos: start searching at this position.
1309 depth: nesting level at endpos.
1310 startchar: expression opening character.
1311 endchar: expression closing character.
1312
1313 Returns:
1314 On finding matching startchar: (index at matching startchar, 0)
1315 Otherwise: (-1, new depth at beginning of this line)
1316 """
1317 for i in xrange(endpos, -1, -1):
1318 if line[i] == endchar:
1319 depth += 1
1320 elif line[i] == startchar:
1321 depth -= 1
1322 if depth == 0:
1323 return (i, 0)
1324 return (-1, depth)
1325
1326
1327def ReverseCloseExpression(clean_lines, linenum, pos):

Callers 1

ReverseCloseExpressionFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected