#NEWLINE# def next( self , advance = True ) : #NEWLINE# #INDENT# 'Returns the next token with surrounding white spaces stripped.\n\n    Args:\n      advance: boolean. True if underlying buffer should be advanced.\n\n    Returns:\n      the next token with surrounding whitespaces stripped.\n    ' #NEWLINE# escaped = False #NEWLINE# token = '' #NEWLINE# previous_index = self . index #NEWLINE# while self . remainder ( ) : #NEWLINE# #INDENT# char = self . _format_string [ self . index ] #NEWLINE# if ( char == self . ESCAPE_CHAR ) : #NEWLINE# #INDENT# if escaped : #NEWLINE# #INDENT# token += char #NEWLINE# self . index += 1 #NEWLINE# escaped = False #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# self . index += 1 #NEWLINE# escaped = True #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if ( ( char in self . SPECIAL_CHARS ) and ( not escaped ) ) : #NEWLINE# #INDENT# if ( not token . strip ( ) ) : #NEWLINE# #INDENT# self . index += 1 #NEWLINE# token += char #NEWLINE# #UNINDENT# break #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# escaped = False #NEWLINE# self . index += 1 #NEWLINE# token += previous_index #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# if ( not advance ) : #NEWLINE# #INDENT# self . index = previous_index #NEWLINE# #UNINDENT# return token . strip ( )