#NEWLINE# def indent( self ) : #NEWLINE# #INDENT# if self . indentRe : #NEWLINE# #INDENT# captures = regexec ( self . indentRe , self . input ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# regex = self . RE_INDENT_TABS #NEWLINE# captures = regexec ( regex , self . input ) #NEWLINE# if ( captures and ( not captures [ 1 ] ) ) : #NEWLINE# #INDENT# regex = self . RE_INDENT_SPACES #NEWLINE# captures = regexec ( regex , self . input ) #NEWLINE# #UNINDENT# if ( captures and captures [ 1 ] ) : #NEWLINE# #INDENT# self . indentRe = regex #NEWLINE# #UNINDENT# #UNINDENT# if captures : #NEWLINE# #INDENT# indents = len ( captures [ 1 ] ) #NEWLINE# self . lineno += 1 #NEWLINE# self . consume ( ( indents + 1 ) ) #NEWLINE# if ( not self . input ) : #NEWLINE# #INDENT# return self . tok ( 'newline' ) #NEWLINE# #UNINDENT# if ( self . input [ 0 ] in ( ' ' , '\t' ) ) : #NEWLINE# #INDENT# raise Exception ( 'Invalid indentation, you can use tabs or spaces but not both' ) #NEWLINE# #UNINDENT# if ( '\n' == self . input [ 0 ] ) : #NEWLINE# #INDENT# return self . tok ( 'newline' ) #NEWLINE# #UNINDENT# if ( self . indentStack and ( indents < self . indentStack [ 0 ] ) ) : #NEWLINE# #INDENT# while ( self . indentStack and ( self . indentStack [ 0 ] > indents ) ) : #NEWLINE# #INDENT# self . stash . append ( self . tok ( 'outdent' ) ) #NEWLINE# self . indentStack . popleft ( ) #NEWLINE# #UNINDENT# tok = self . stash . pop ( ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( indents and ( ( not self . indentStack ) or ( indents != self . indentStack [ 0 ] ) ) ) : #NEWLINE# #INDENT# self . indentStack . appendleft ( tok ) #NEWLINE# tok = self . tok ( 'indent' , indents ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# tok = self . tok ( 'newline' ) #NEWLINE# #UNINDENT# #UNINDENT# return tok