import sys


def transform(line):
    line = line.strip('[],\n SWAP(); ')
    if line:
        x, y = map(int, line.split(', '))
        return 'iter_swap_if(first + {0}u, first + {1}u, compare, projection);'.format(x, y)


if __name__ == '__main__':
    with open(sys.argv[1]) as source:
        for line in source:
            pairs = line.split('],[')
            for pair in pairs:
                res = transform(pair)
                if res:
                    print(res)

@@ -59,17 +59,15 @@
 %5D,%5Cn
- 
 SWAP();
- 
 ')%0A 
@@ -115,17 +115,16 @@
 split(',
- 
 '))%0A    
@@ -299,32 +299,157 @@
 line in source:%0A
+            line = line.replace(' ', '')%0A            line = line.replace('(', '%5B')%0A            line = line.replace(')', '%5D')%0A
             pair

Tweak generate.py