import ast


def _parse_source(code, cait_report):
    """
    Parses the given code and returns its Cait representation. If the parse was
    unsuccessful, it attaches the error to the report.

    Args:
        code (str): A string of Python code.
        cait_report (dict): A Cait Report to store information in.
    Returns:
        AstNode: The parsed AST reprensetation, or None
    """
    try:
        parsed = ast.parse(code)
    except SyntaxError as e:
        cait_report['success'] = False
        cait_report['error'] = e
        return ast.parse("")
    return parsed