def handle_word(self, token_text):
    if self.start_of_statement():
        pass
    elif (self.input_wanted_newline and (not self.is_expression(self.flags.mode)) and ((self.last_type != 'TK_OPERATOR') or ((self.flags.last_text == '--') or (self.flags.last_text == '++'))) and (self.last_type != 'TK_EQUALS') and (self.opts.preserve_newlines or (not ((self.last_type == 'TK_RESERVED') and (self.flags.last_text in ['var', 'let', 'const', 'set', 'get']))))):
        self.append_newline()
    if (self.flags.do_block and (not self.flags.do_while)):
        if ((self.token_type == 'TK_RESERVED') and (token_text == 'while')):
            self.output_space_before_token = True
            self.append_token(token_text)
            self.output_space_before_token = True
            self.flags.do_while = True
            return
        else:
            self.append_newline()
            self.flags.do_block = False
    if self.flags.if_block:
        if ((not self.flags.else_block) and ((self.token_type == 'TK_RESERVED') and (token_text == 'else'))):
            self.flags.else_block = True
        else:
            while (self.flags.mode == MODE.Statement):
                self.restore_mode()
            self.flags.if_block = False
    if ((self.token_type == 'TK_RESERVED') and ((token_text == 'case') or ((token_text == 'default') and self.flags.in_case_statement))):
        self.append_newline()
        if (self.flags.case_body or self.opts.jslint_happy):
            self.flags.case_body = False
            self.deindent()
        self.append_token(token_text)
        self.flags.in_case = True
        self.flags.in_case_statement = True
        return
    if ((self.token_type == 'TK_RESERVED') and (token_text == 'function')):
        if ((self.flags.last_text in ['}', ';']) or (self.just_added_newline() and (not (self.flags.last_text in ['{', ':', '=', ','])))):
            if ((not self.just_added_blankline()) and (not self.flags.had_comment)):
                self.append_newline()
                self.append_newline(True)
        if ((self.last_type == 'TK_RESERVED') or (self.last_type == 'TK_WORD')):
            if ((self.last_type == 'TK_RESERVED') and (self.flags.last_text in ['get', 'set', 'new', 'return'])):
                self.output_space_before_token = True
            else:
                self.append_newline()
        elif ((self.last_type == 'TK_OPERATOR') or (self.flags.last_text == '=')):
            self.output_space_before_token = True
        elif self.is_expression(self.flags.mode):
            pass
        else:
            self.append_newline()
    if (self.last_type in ['TK_COMMA', 'TK_START_EXPR', 'TK_EQUALS', 'TK_OPERATOR']):
        if (not self.start_of_object_property()):
            self.allow_wrap_or_preserved_newline(token_text)
    if ((self.token_type == 'TK_RESERVED') and (token_text == 'function')):
        self.append_token(token_text)
        self.flags.last_word = token_text
        return
    prefix = 'NONE'
    if (self.last_type == 'TK_END_BLOCK'):
        if (not ((self.token_type == 'TK_RESERVED') and (token_text in ['else', 'catch', 'finally']))):
            prefix = 'NEWLINE'
        elif (self.opts.brace_style in ['expand', 'end-expand']):
            prefix = 'NEWLINE'
        else:
            prefix = 'SPACE'
            self.output_space_before_token = True
    elif ((self.last_type == 'TK_SEMICOLON') and (self.flags.mode == MODE.BlockStatement)):
        prefix = 'NEWLINE'
    elif ((self.last_type == 'TK_SEMICOLON') and self.is_expression(self.flags.mode)):
        prefix = 'SPACE'
    elif (self.last_type == 'TK_STRING'):
        prefix = 'NEWLINE'
    elif ((self.last_type == 'TK_RESERVED') or (self.last_type == 'TK_WORD') or ((self.flags.last_text == '*') and (self.last_last_text == 'function'))):
        prefix = 'SPACE'
    elif (self.last_type == 'TK_START_BLOCK'):
        prefix = 'NEWLINE'
    elif (self.last_type == 'TK_END_EXPR'):
        self.output_space_before_token = True
        prefix = 'NEWLINE'
    if ((self.token_type == 'TK_RESERVED') and (token_text in self.line_starters) and (self.flags.last_text != ')')):
        if (self.flags.last_text == 'else'):
            prefix = 'SPACE'
        else:
            prefix = 'NEWLINE'
    if ((self.token_type == 'TK_RESERVED') and (token_text in ['else', 'catch', 'finally'])):
        if ((self.last_type != 'TK_END_BLOCK') or (self.opts.brace_style == 'expand') or (self.opts.brace_style == 'end-expand')):
            self.append_newline()
        else:
            self.trim_output(True)
            line = self.output_lines[(- 1)]
            if (line.text[(- 1)] != '}'):
                self.append_newline()
            self.output_space_before_token = True
    elif (prefix == 'NEWLINE'):
        if ((self.last_type == 'TK_RESERVED') and self.is_special_word(self.flags.last_text)):
            self.output_space_before_token = True
        elif (self.last_type != 'TK_END_EXPR'):
            if (((self.last_type != 'TK_START_EXPR') or (not ((self.token_type == 'TK_RESERVED') and (token_text in ['var', 'let', 'const'])))) and (self.flags.last_text != ':')):
                if ((self.token_type == 'TK_RESERVED') and (token_text == 'if') and (self.flags.last_word == 'else') and (self.flags.last_text != '{')):
                    self.output_space_before_token = True
                else:
                    self.append_newline()
        elif ((self.token_type == 'TK_RESERVED') and (token_text in self.line_starters) and (self.flags.last_text != ')')):
            self.append_newline()
    elif (self.is_array(self.flags.mode) and (self.flags.last_text == ',') and (self.last_last_text == '}')):
        self.append_newline()
    elif (prefix == 'SPACE'):
        self.output_space_before_token = True
    self.append_token(token_text)
    self.flags.last_word = token_text
    if ((self.token_type == 'TK_RESERVED') and (token_text == 'do')):
        self.flags.do_block = True
    if ((self.token_type == 'TK_RESERVED') and (token_text == 'if')):
        self.flags.if_block = True
def handle_word(self, token_text):
    if self.start_of_statement():
        pass
    elif (self.input_wanted_newline and (not self.is_expression(self.flags.mode)) and ((self.last_type != 'TK_OPERATOR') or ((self.flags.last_text == '--') or (self.flags.last_text == '++'))) and (self.last_type != 'TK_EQUALS') and (self.opts.preserve_newlines or (not ((self.last_type == 'TK_RESERVED') and (self.flags.last_text in ['var', 'let', 'const', 'set', 'get']))))):
        self.append_newline()
    if (self.flags.do_block and (not self.flags.do_while)):
        if ((self.token_type == 'TK_RESERVED') and (token_text == 'while')):
            self.output_space_before_token = True
            self.append_token(token_text)
            self.output_space_before_token = True
            self.flags.do_while = True
            return
        else:
            self.append_newline()
            self.flags.do_block = False
    if self.flags.if_block:
        if ((not self.flags.else_block) and ((self.token_type == 'TK_RESERVED') and (token_text == 'else'))):
            self.flags.else_block = True
        else:
            while (self.flags.mode == MODE.Statement):
                self.restore_mode()
            self.flags.if_block = False
    if ((self.token_type == 'TK_RESERVED') and ((token_text == 'case') or ((token_text == 'default') and self.flags.in_case_statement))):
        self.append_newline()
        if (self.flags.case_body or self.opts.jslint_happy):
            self.flags.case_body = False
            self.deindent()
        self.append_token(token_text)
        self.flags.in_case = True
        self.flags.in_case_statement = True
        return
    if ((self.token_type == 'TK_RESERVED') and (token_text == 'function')):
        if ((self.flags.last_text in ['}', ';']) or (self.just_added_newline() and (not (self.flags.last_text in ['{', ':', '=', ','])))):
            if ((not self.just_added_blankline()) and (not self.flags.had_comment)):
                self.append_newline()
                self.append_newline(True)
        if ((self.last_type == 'TK_RESERVED') or (self.last_type == 'TK_WORD')):
            if ((self.last_type == 'TK_RESERVED') and (self.flags.last_text in ['get', 'set', 'new', 'return'])):
                self.output_space_before_token = True
            else:
                self.append_newline()
        elif ((self.last_type == 'TK_OPERATOR') or (self.flags.last_text == '=')):
            self.output_space_before_token = True
        elif self.is_expression(self.flags.mode):
            pass
        else:
            self.append_newline()
    if (self.last_type in ['TK_COMMA', 'TK_START_EXPR', 'TK_EQUALS', 'TK_OPERATOR']):
        if (not self.start_of_object_property()):
            self.allow_wrap_or_preserved_newline(token_text)
    if ((self.token_type == 'TK_RESERVED') and (token_text == 'function')):
        self.append_token(token_text)
        self.flags.last_word = token_text
        return
    prefix = 'NONE'
    if (self.last_type == 'TK_END_BLOCK'):
        if (not ((self.token_type == 'TK_RESERVED') and (token_text in ['else', 'catch', 'finally']))):
            prefix = 'NEWLINE'
        elif (self.opts.brace_style in ['expand', 'end-expand']):
            prefix = 'NEWLINE'
        else:
            prefix = 'SPACE'
            self.output_space_before_token = True
    elif ((self.last_type == 'TK_SEMICOLON') and (self.flags.mode == MODE.BlockStatement)):
        prefix = 'NEWLINE'
    elif ((self.last_type == 'TK_SEMICOLON') and self.is_expression(self.flags.mode)):
        prefix = 'SPACE'
    elif (self.last_type == 'TK_STRING'):
        prefix = 'NEWLINE'
    elif ((self.last_type == 'TK_RESERVED') or (self.last_type == 'TK_WORD') or ((self.flags.last_text == '*') and (self.last_last_text == 'function'))):
        prefix = 'SPACE'
    elif (self.last_type == 'TK_START_BLOCK'):
        prefix = 'NEWLINE'
    elif (self.last_type == 'TK_END_EXPR'):
        self.output_space_before_token = True
        prefix = 'NEWLINE'
    if ((self.token_type == 'TK_RESERVED') and (token_text in self.line_starters) and (self.flags.last_text != ')')):
        if (self.flags.last_text == 'else'):
            prefix = 'SPACE'
        else:
            prefix = 'NEWLINE'
    if ((self.token_type == 'TK_RESERVED') and (token_text in ['else', 'catch', 'finally'])):
        if ((self.last_type != 'TK_END_BLOCK') or (self.opts.brace_style == 'expand') or (self.opts.brace_style == 'end-expand')):
            self.append_newline()
        else:
            self.trim_output(True)
            line = self.output_lines[(- 1)]
            if (line.text[(- 1)] != '}'):
                self.append_newline()
            self.output_space_before_token = True
    elif (prefix == 'NEWLINE'):
        if ((self.last_type == 'TK_RESERVED') and self.is_special_word(self.flags.last_text)):
            self.output_space_before_token = True
        elif (self.last_type != 'TK_END_EXPR'):
            if (((self.last_type != 'TK_START_EXPR') or (not ((self.token_type == 'TK_RESERVED') and (token_text in ['var', 'let', 'const'])))) and (self.flags.last_text != ':')):
                if ((self.token_type == 'TK_RESERVED') and (token_text == 'if') and (self.flags.last_word == 'else') and (self.flags.last_text != '{')):
                    self.output_space_before_token = True
                else:
                    self.append_newline()
        elif ((self.token_type == 'TK_RESERVED') and (token_text in self.line_starters) and (self.flags.last_text != ')')):
            self.append_newline()
    elif (self.is_array(self.flags.mode) and (self.flags.last_text == ',') and (self.last_last_text == '}')):
        self.append_newline()
    elif (prefix == 'SPACE'):
        self.output_space_before_token = True
    self.append_token(token_text)
    self.flags.last_word = token_text
    if ((self.token_type == 'TK_RESERVED') and (token_text == 'do')):
        self.flags.do_block = True
    if ((self.token_type == 'TK_RESERVED') and (token_text == 'if')):
        self.flags.if_block = True