def split_add_ops(text):
 n = 0
 text = text.replace('++', '##').replace('--', '@@')
 spotted = False
 last = 0
 while (n < len(text)):
  e = text[n]
  if ((e == '+') or (e == '-')):
   if spotted:
    (yield text[last:n].replace('##', '++').replace('@@', '--'))
    (yield e)
    last = (n + 1)
    spotted = False
  elif ((e == '/') or (e == '*') or (e == '%')):
   spotted = False
  elif (e != ' '):
   spotted = True
  n += 1
 (yield text[last:n].replace('##', '++').replace('@@', '--'))

def split_add_ops ( text ) : n = 0 text = text . replace ( '++' , '##' ) . replace ( '--' , '@@' ) spotted = False last = 0 while ( n < len ( text ) ) : e = text [ n ] if ( ( e == '+' ) or ( e == '-' ) ) : if spotted : ( yield text [ last : n ] . replace ( '##' , '++' ) . replace ( '@@' , '--' ) ) ( yield e ) last = ( n + 1 ) spotted = False elif ( ( e == '/' ) or ( e == '*' ) or ( e == '%' ) ) : spotted = False elif ( e != ' ' ) : spotted = True n += 1 ( yield text [ last : n ] . replace ( '##' , '++' ) . replace ( '@@' , '--' ) )
specialized function splitting text at add/sub operators .