def _parse_till_closing_brace(stream):
 rv = ''
 in_braces = 1
 while True:
  if EscapeCharToken.starts_here(stream, '{}'):
   rv += (next(stream) + next(stream))
  else:
   char = next(stream)
   if (char == '{'):
    in_braces += 1
   elif (char == '}'):
    in_braces -= 1
   if (in_braces == 0):
    break
   rv += char
 return rv

def _parse_till_closing_brace ( stream ) : rv = '' in_braces = 1 while True : if EscapeCharToken . starts_here ( stream , '{}' ) : rv += ( next ( stream ) + next ( stream ) ) else : char = next ( stream ) if ( char == '{' ) : in_braces += 1 elif ( char == '}' ) : in_braces -= 1 if ( in_braces == 0 ) : break rv += char return rv
returns all chars till a non-escaped } is found .