<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def from_file(cls, path, directory=None, modules=None, active=None):
 """ Instantiate a REPP from a `.rpp` file. The *path* parameter points to the top-level module. Submodules are loaded from *directory*. If *directory* is not given, it is the directory part of *path*. A REPP module may utilize external submodules, which may be defined in two ways. The first method is to map a module name to an instantiated REPP instance in *modules*. The second method assumes that an external group call `>abc` corresponds to a file `abc.rpp` in *directory* and loads that file. The second method only happens if the name (e.g., `abc`) does not appear in *modules*. Only one module may define a tokenization pattern. Args: path (str):
 the path to the base REPP file to load directory (str, optional):
 the directory in which to search for submodules modules (dict, optional):
 a mapping from identifiers to REPP modules active (iterable, optional):
 an iterable of default module activations """

        name = basename(path)
        if name.endswith('.rpp'):
            name = name[:-4]
        lines = _repp_lines(path)
        directory = dirname(path) if directory is None else directory
        r = cls(name=name, modules=modules, active=active)
        _parse_repp(lines, r, directory)
        return r