MCPcopy Create free account
hub / github.com/BVLC/caffe / FindEndOfExpressionInLine

Function FindEndOfExpressionInLine

scripts/cpp_lint.py:1234–1255  ·  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

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

Callers 2

CloseExpressionFunction · 0.85
CheckCheckFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected