parameters: (clean_lines, linenum, pos)
return_statement: return (line, linenum, endpos + 1)
docstring: If input points to ( or { or [, finds the position that closes it.
  
    If lines[linenum][pos] points to a '(' or '{' or '[', finds the
    linenum/pos that correspond to the closing of the expression.
  
    Args:
      clean_lines: A CleansedLines instance containing the file.
      linenum: The number of the line to check.
      pos: A position on the line.
  
    Returns:
      A tuple (line, linenum, pos) pointer *past* the closing brace, or
      (line, len(lines), -1) if we never find a close.  Note we ignore
      strings and comments when matching; and the line we return is the
      'cleansed' line at linenum.
docstring_summary: If input points to ( or { or [, finds the position that closes it.
docstring_tokens: If input points to ( or { or [ finds the position that closes it .
function: def CloseExpression(clean_lines, linenum, pos):
    """If input points to ( or { or [, finds the position that closes it.
  
    If lines[linenum][pos] points to a '(' or '{' or '[', finds the
    linenum/pos that correspond to the closing of the expression.
  
    Args:
      clean_lines: A CleansedLines instance containing the file.
      linenum: The number of the line to check.
      pos: A position on the line.
  
    Returns:
      A tuple (line, linenum, pos) pointer *past* the closing brace, or
      (line, len(lines), -1) if we never find a close.  Note we ignore
      strings and comments when matching; and the line we return is the
      'cleansed' line at linenum.
    """
  
    line = clean_lines.elided[linenum]
    startchar = line[pos]
    if startchar not in '({[':
      return (line, clean_lines.NumLines(), -1)
    if startchar == '(': endchar = ')'
    if startchar == '[': endchar = ']'
    if startchar == '{': endchar = '}'
  
    num_open = line.count(startchar) - line.count(endchar)
    while linenum < clean_lines.NumLines() and num_open > 0:
      linenum += 1
      line = clean_lines.elided[linenum]
      num_open += line.count(startchar) - line.count(endchar)
    # OK, now find the endchar that actually got us back to even
    endpos = len(line)
    while num_open >= 0:
      endpos = line.rfind(')', 0, endpos)
      num_open -= 1                 # chopped off another )
    return (line, linenum, endpos + 1)
function_tokens: def CloseExpression ( clean_lines , linenum , pos ) : line = clean_lines . elided [ linenum ] startchar = line [ pos ] if startchar not in '({[' : return ( line , clean_lines . NumLines ( ) , - 1 ) if startchar == '(' : endchar = ')' if startchar == '[' : endchar = ']' if startchar == '{' : endchar = '}' num_open = line . count ( startchar ) - line . count ( endchar ) while linenum < clean_lines . NumLines ( ) and num_open > 0 : linenum += 1 line = clean_lines . elided [ linenum ] num_open += line . count ( startchar ) - line . count ( endchar ) # OK, now find the endchar that actually got us back to even endpos = len ( line ) while num_open >= 0 : endpos = line . rfind ( ')' , 0 , endpos ) num_open -= 1 # chopped off another ) return ( line , linenum , endpos + 1 )