The script defines two functions, DIFF and PATCH. DIFF accepts two files (or blocks of strings, or ports in /lines mode), and returns a dialect block representing the differences between the two files. The result is so that if you apply it with PATCH to the first file, you get the second file.
PATCH accepts a file (or block, or port in /lines mode) and a diff block, and applies the differences to the file.
The dialect block is made of integers and strings. A positive integer means inserting new lines at that (absolute) offset, and it is followed by some strings representing the new lines to insert. A negative integer means removing lines, and it is followed by a positive integer indicating the number of lines to be removed. See the source of PATCH for more details about how to handle a diff block.