def METHOD_NAME(filename, basename):
    """Read a Quint file into two buffers: the source code and the document"""
    comment_start = re.compile('^\s*/\*!\s*$')
    comment_end = re.compile('^\s*!\*/\s*$')
    # Collect the source code and the document in memory.
    # Our files are small, so this should work fine.
    code = []
    doc = []
    with open(filename, "r") as fi:
        line = fi.readline()
        state = PreproState.CODE
        nLines = 0
        while line:
            if state == PreproState.CODE:
                if comment_start.match(line):
                    state = PreproState.DOC
                else:
                    code.append(line)
                    nLines += 1
            elif state == PreproState.DOC:
                if comment_end.match(line):
                    state = PreproState.CODE
                else:
                    # replace $line with the line number in the code
                    ppline = \
                        line.replace("$line", str(nLines - 1 if nLines > 0 else 0)) \
                            .replace("$file", basename + ".qnt")
                    doc.append(ppline)
            else:
                assert(False)
            line = fi.readline()
    return (code, doc)