<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def parse_file(self, sg_file=None, data=None):
 """Parse a sensor graph file into an AST describing the file. This function builds the statements list for this parser. If you pass ``sg_file``, it will be interpreted as the path to a file to parse. If you pass ``data`` it will be directly interpreted as the string to parse. """


        if sg_file is not None and data is not None:
            raise ArgumentError("You must pass either a path to an sgf file or the sgf contents but not both")

        if sg_file is None and data is None:
            raise ArgumentError("You must pass either a path to an sgf file or the sgf contents, neither passed")

        if sg_file is not None:
            try:
                with open(sg_file, "r") as inf:
                    data = inf.read()
            except IOError:
                raise ArgumentError("Could not read sensor graph file", path=sg_file)

        # convert tabs to spaces so our line numbers match correctly
        data = data.replace(u'\t', u'    ')

        lang = get_language()
        result = lang.parseString(data)

        for statement in result:
            parsed = self.parse_statement(statement, orig_contents=data)
            self.statements.append(parsed)