def extract_table_identifiers(token_stream):
for item in token_stream:<EOL><INDENT>if isinstance(item, IdentifierList):<EOL><INDENT>for identifier in item.get_identifiers():<EOL><INDENT>try:<EOL><INDENT>schema_name = identifier.get_parent_name()<EOL>real_name = identifier.get_real_name()<EOL><DEDENT>except AttributeError:<EOL><INDENT>continue<EOL><DEDENT>if real_name:<EOL><INDENT>yield (schema_name, real_name, identifier.get_alias())<EOL><DEDENT><DEDENT><DEDENT>elif isinstance(item, Identifier):<EOL><INDENT>real_name = item.get_real_name()<EOL>schema_name = item.get_parent_name()<EOL>if real_name:<EOL><INDENT>yield (schema_name, real_name, item.get_alias())<EOL><DEDENT>else:<EOL><INDENT>name = item.get_name()<EOL>yield (None, name, item.get_alias() or name)<EOL><DEDENT><DEDENT>elif isinstance(item, Function):<EOL><INDENT>yield (None, item.get_name(), item.get_name())<EOL><DEDENT><DEDENT>
yields tuples of (schema_name, table_name, table_alias)