def _IsType(clean_lines, nesting_state, expr):
<EOL>last_word = Match(r'<STR_LIT>', expr)<EOL>if last_word:<EOL><INDENT>token = last_word.group(<NUM_LIT:1>)<EOL><DEDENT>else:<EOL><INDENT>token = expr<EOL><DEDENT>if _TYPES.match(token):<EOL><INDENT>return True<EOL><DEDENT>typename_pattern = (r'<STR_LIT>' + re.escape(token) +<EOL>r'<STR_LIT>')<EOL>block_index = len(nesting_state.stack) - <NUM_LIT:1><EOL>while block_index >= <NUM_LIT:0>:<EOL><INDENT>if isinstance(nesting_state.stack[block_index], _NamespaceInfo):<EOL><INDENT>return False<EOL><DEDENT>last_line = nesting_state.stack[block_index].starting_linenum<EOL>next_block_start = <NUM_LIT:0><EOL>if block_index > <NUM_LIT:0>:<EOL><INDENT>next_block_start = nesting_state.stack[block_index - <NUM_LIT:1>].starting_linenum<EOL><DEDENT>first_line = last_line<EOL>while first_line >= next_block_start:<EOL><INDENT>if clean_lines.elided[first_line].find('<STR_LIT>') >= <NUM_LIT:0>:<EOL><INDENT>break<EOL><DEDENT>first_line -= <NUM_LIT:1><EOL><DEDENT>if first_line < next_block_start:<EOL><INDENT>block_index -= <NUM_LIT:1><EOL>continue<EOL><DEDENT>for i in xrange(first_line, last_line + <NUM_LIT:1>, <NUM_LIT:1>):<EOL><INDENT>if Search(typename_pattern, clean_lines.elided[i]):<EOL><INDENT>return True<EOL><DEDENT><DEDENT>block_index -= <NUM_LIT:1><EOL><DEDENT>return False<EOL>
Check if expression looks like a type name, returns true if so.

    Args:
      clean_lines: A CleansedLines instance containing the file.
      nesting_state: A NestingState instance which maintains information about
                     the current stack of nested blocks being parsed.
      expr: The expression to check.
    Returns:
      True, if token looks like a type.