def FindStartOfExpressionInLine(line, endpos, stack):
 i = endpos
 while (i >= 0):
  char = line[i]
  if (char in ')]}'):
   stack.append(char)
  elif (char == '>'):
   if ((i > 0) and ((line[(i - 1)] == '-') or Match('\\s>=\\s', line[(i - 1):]) or Search('\\boperator\\s*$', line[0:i]))):
    i -= 1
   else:
    stack.append('>')
  elif (char == '<'):
   if ((i > 0) and (line[(i - 1)] == '<')):
    i -= 1
   elif (stack and (stack[(-1)] == '>')):
    stack.pop()
    if (not stack):
     return (i, None)
  elif (char in '([{'):
   while (stack and (stack[(-1)] == '>')):
    stack.pop()
   if (not stack):
    return ((-1), None)
   if (((char == '(') and (stack[(-1)] == ')')) or ((char == '[') and (stack[(-1)] == ']')) or ((char == '{') and (stack[(-1)] == '}'))):
    stack.pop()
    if (not stack):
     return (i, None)
   else:
    return ((-1), None)
  elif (char == ';'):
   while (stack and (stack[(-1)] == '>')):
    stack.pop()
   if (not stack):
    return ((-1), None)
  i -= 1
 return ((-1), stack)

def FindStartOfExpressionInLine ( line , endpos , stack ) : i = endpos while ( i >= 0 ) : char = line [ i ] if ( char in ')]}' ) : stack . append ( char ) elif ( char == '>' ) : if ( ( i > 0 ) and ( ( line [ ( i - 1 ) ] == '-' ) or Match ( '\\s>=\\s' , line [ ( i - 1 ) : ] ) or Search ( '\\boperator\\s*$' , line [ 0 : i ] ) ) ) : i -= 1 else : stack . append ( '>' ) elif ( char == '<' ) : if ( ( i > 0 ) and ( line [ ( i - 1 ) ] == '<' ) ) : i -= 1 elif ( stack and ( stack [ ( - 1 ) ] == '>' ) ) : stack . pop ( ) if ( not stack ) : return ( i , None ) elif ( char in '([{' ) : while ( stack and ( stack [ ( - 1 ) ] == '>' ) ) : stack . pop ( ) if ( not stack ) : return ( ( - 1 ) , None ) if ( ( ( char == '(' ) and ( stack [ ( - 1 ) ] == ')' ) ) or ( ( char == '[' ) and ( stack [ ( - 1 ) ] == ']' ) ) or ( ( char == '{' ) and ( stack [ ( - 1 ) ] == '}' ) ) ) : stack . pop ( ) if ( not stack ) : return ( i , None ) else : return ( ( - 1 ) , None ) elif ( char == ';' ) : while ( stack and ( stack [ ( - 1 ) ] == '>' ) ) : stack . pop ( ) if ( not stack ) : return ( ( - 1 ) , None ) i -= 1 return ( ( - 1 ) , stack )
find position at the matching startchar .