'Loops over the styles in the document and stores important info.
When enough info is gathered, will perform a call to analyze the code
and generate subsequent language structures. These language structures
will later be used to generate XML output for the document.'

def token_next(self, style, text, start_column, start_line, **other_args):

    if (style in self.JS_CILE_STYLES):
        start_line += 1
        if ((self.state == S_DEFAULT) and (len(self.styles) > 0) and (self.last_lineno < start_line)):
            if (((style != self.JS_OPERATOR) or (text[0] not in '({[.,=')) and ((self.styles[(-1)] != self.JS_OPERATOR) or (self.text[(-1)] not in '({[.,=')) and ((self.styles[(-1)] != self.JS_WORD) or (self.text[(-1)] != 'new'))):
                self._addCodePiece(self.styles, self.text, pos=0)
                self.in_variable_definition = False
        self.lineno = start_line
        if (style != self.JS_OPERATOR):
            self.styles.append(style)
            self.text.append(text)
        else:
            if (text == '('):
                if (not self.text):
                    log.debug("Ignoring    initial    brace:    '('    on    line    %d", self.lineno)
                    return
            next_op_index = 0
            while (next_op_index < len(text)):
                op = text[next_op_index]
                next_op_index += 1
                self.styles.append(style)
                self.text.append(op)
                if (op == '('):
                    if (self.bracket_depth == 0):
                        log.debug('Entering    S_IN_ARGS    state,    line:    %d,    col:    %d', start_line, start_column)
                        newscope = self._findScopeFromContext(self.styles, self.text)
                        self._pushAndSetState(S_IN_ARGS)
                        if (newscope and (self.currentScope != newscope)):
                            log.debug('Adjusting    scope    to:    %r    %r', newscope.cixname, newscope.name)
                            self.currentScope = newscope
                        self.argumentTextPosition = len(self.text)
                    self.bracket_depth += 1
                elif (op == ')'):
                    self.bracket_depth -= 1
                    if (self.bracket_depth <= 0):
                        last_state = self.state
                        self._popPreviousState(keep_style_and_text=True)
                        if ((self.state != S_IN_ARGS) and (last_state == S_IN_ARGS)):
                            self._handleFunctionWithArguments()
                        log.debug('Entering    state    %d,    line:    %d,    col:    %d', self.state, start_line, start_column)
                    elif (isinstance(self.lastScope, JSFunction) and (self.text[(-3):] == ['{', '(', ')'])):
                        self.lastScope = self._convertFunctionToClosureVariable(self.lastScope)
                elif (op == '='):
                    try:
                        next_ch = text[next_op_index]
                    except IndexError:
                        continue
                    if (next_ch == '>'):
                        self.text[(-1)] = '=>'
                        next_op_index += 1
                elif (op == '{'):
                    if (self.state == S_IN_ARGS):
                        argTextPos = self.argumentTextPosition
                        if ((len(self.text) >= 2) and (self.text[(-2)] == ')')):
                            try:
                                argsStart = (len(self.text) - list(reversed(self.text)).index('('))
                                if (argsStart > 1):
                                    functionPos = (argsStart - 2)
                                    if (self.styles[functionPos] == self.JS_IDENTIFIER):
                                        functionPos -= 1
                                    if ((functionPos > (-1)) and (self.styles[functionPos] == self.JS_WORD) and (self.text[functionPos] == 'function')):
                                        args = self.text[argsStart:(-2)]
                                        if all(((x == ',') for x in args[1::2])):
                                            obj = self.addAnonymousFunction(args=args[::2])
                                            self._pushAndSetState(S_DEFAULT)
                            except ValueError:
                                pass
                        elif ((len(self.text) >= 2) and (((self.text[(-2)] == '(') and (self.argumentPosition == 0)) or ((self.text[(-2)] == ',') and (self.argumentPosition > 0)))):
                            log.debug('Entering    S_OBJECT_ARGUMENT    state,    line:    %d,    col:    %d', start_line, start_column)
                            obj = self.createObjectArgument(self.styles, self.text)
                            self.currentScope = obj
                            self._pushAndSetState(S_OBJECT_ARGUMENT)
                        else:
                            self._pushAndSetState(S_IN_ARGS)
                    else:
                        self._addCodePiece(self.styles, self.text, pos=0)
                        self._pushAndSetState(S_DEFAULT)
                    self.incBlock()
                elif (op == '}'):
                    previous_state = self.state
                    if (self.state != S_IN_ARGS):
                        self._addCodePiece(self.styles, self.text, pos=0)
                    self._popPreviousState()
                    if (self.state == S_IN_ARGS):
                        self.objectArguments.append((self.argumentPosition, self.currentScope))
                        log.debug('Leaving    S_OBJECT_ARGUMENT    state,    entering    S_IN_ARGS    state,    line:    %d,    col:    %d', start_line, start_column)
                    self.decBlock()
                elif ((op == ',') and (self.text[0] not in ('let', 'var', 'const'))):
                    if (self.state == S_IN_ARGS):
                        self.argumentPosition += 1
                        self.argumentTextPosition = len(self.text)
                    else:
                        self._addCodePiece(self.styles, self.text, pos=0)
                elif (op == ';'):
                    if (self.state != S_IN_ARGS):
                        self._addCodePiece(self.styles, self.text, pos=0)
                    self.in_variable_definition = False
        self.last_lineno = self.lineno
    elif (style in self.JS_COMMENT_STYLES):
        self.comment.append(text)
