-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCompile.py
More file actions
44 lines (36 loc) · 9.37 KB
/
Compile.py
File metadata and controls
44 lines (36 loc) · 9.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
dict_ce0 = {0: '0x0%0xe', 12: '0xc%0xe', 2: '0xe%0xc', 14: '0xe%0xee', 10: '0xc0%0xe', 8: '0xcc%0xe', 32: '0xe0%0xc0', 20: '0xe0%0xcc', 18: '0xe0%0xce', 44: '0xec%0xc0', 30: '0xec%0xce', 46: '0xee%0xc0', 34: '0xee%0xcc', 6: '0xc00%0xe', 4: '0xc0c%0xe', 24: '0xc0c%0xcc', 16: '0xc0c%0xec', 26: '0xc0e%0xcc', 116: '0xe00%0xcc', 82: '0xe00%0xce', 94: '0xe0c%0xce', 56: '0xe0c%0xec', 96: '0xe0e%0xce', 58: '0xe0e%0xec', 28: '0xe0e%0xee', 104: '0xec0%0xcc', 68: '0xec0%0xce', 80: '0xecc%0xce', 118: '0xece%0xcc', 100: '0xee0%0xce', 112: '0xeec%0xce', 114: '0xeee%0xce', 124: '0xc000%0xee', 64: '0xc000%0xec', 108: '0xc00c%0xe0', 76: '0xc00c%0xec', 110: '0xc00e%0xe0', 78: '0xc00e%0xec', 74: '0xe0cc%0xce', 122: '0xc0cc%0xce', 90: '0xc0cc%0xee', 86: '0xc0cc%0xece', 92: '0xc0ce%0xee', 88: '0xcce0%0xee', 52: '0xc0e0%0xec', 106: '0xcc00%0xce', 22: '0xc0ee%0xcc', 66: '0xc0ee%0xec', 120: '0xcc0e%0xce', 102: '0xcc00%0xee', 36: '0xcccc%0xec', 38: '0xccce%0xec', 70: '0xccce%0xee', 62: '0xe0c0%0xce', 40: '0xe0e0%0xcc', 54: '0xe0ee%0xcc', 72: '0xec0e%0xce', 42: '0xeeee%0xec', 48: '0xc00cc%0xec', 50: '0xc00ce%0xec', 84: '0xc0c00%0xec', 126: '0xc0c0e%0xce', 98: '0xc0c0e%0xec', 60: '0xc0ecc%0xee'}
dict_bce0 = {0: '0x0%0xe', 11: '0xb%0xe', 1: '0xc%0xb', 12: '0xc%0xe', 3: '0xe%0xb', 2: '0xe%0xc', 14: '0xe%0xee', 8: '0xcc%0xe', 7: '0xcb%0xe', 5: '0xc0%0xb', 6: '0xc00%0xe', 10: '0xc0%0xe', 16: '0xc0c%0xec', 4: '0xc0c%0xe', 27: '0xc00%0xcb', 15: '0xc0b%0xec', 13: '0xccb%0xe', 28: '0xe0e%0xee', 17: '0xc00%0xeb', 30: '0xec%0xce', 19: '0xc0eb%0xcc', 18: '0xe0%0xce', 48: '0xc00cc%0xec', 37: '0xc000%0xeb', 36: '0xcccc%0xec', 34: '0xee%0xcc', 32: '0xe0%0xc0', 21: '0xe0%0xcb', 20: '0xe0%0xcc', 59: '0xe00%0xeb', 47: '0xc0e0%0xcb', 45: '0xc00cb%0xee', 43: '0xeb%0xc0', 31: '0xeb%0xcc', 29: '0xeb%0xce', 60: '0xc0ecc%0xee', 49: '0xc00c%0xeb', 46: '0xee%0xc0', 44: '0xec%0xc0', 33: '0xec%0xcb', 62: '0xe0c0%0xce', 51: '0xc00e%0xeb', 50: '0xc00ce%0xec', 35: '0xee%0xcb', 22: '0xc0ee%0xcc', 23: '0xc0b%0xcc', 25: '0xe0b%0xee', 112: '0xeec%0xce', 108: '0xc00c%0xe0', 80: '0xecc%0xce', 123: '0xc00ec%0xeb', 119: '0xce0b%0xec', 91: '0xc000b%0xee', 124: '0xc000%0xee', 120: '0xcc0e%0xce', 92: '0xc0ce%0xee', 126: '0xc0c0e%0xce', 122: '0xc0cc%0xce', 94: '0xe0c%0xce', 96: '0xe0e%0xce', 9: '0xccc%0xb', 107: '0xc00b%0xe0', 110: '0xc00e%0xe0', 64: '0xc000%0xec', 69: '0xec0b%0xce', 68: '0xec0%0xce', 66: '0xc0ee%0xec', 53: '0xcc00%0xcb', 52: '0xc0e0%0xec', 75: '0xc00b%0xec', 38: '0xccce%0xec', 79: '0xecb%0xce', 77: '0xee0e%0xeb', 63: '0xc0eb%0xec', 61: '0xc0ee%0xcb', 76: '0xc00c%0xec', 39: '0xc0c%0xcb', 24: '0xc0c%0xcc', 81: '0xe0c00%0xeb', 78: '0xc00e%0xec', 65: '0xcc0c%0xcb', 41: '0xc0e%0xcb', 26: '0xc0e%0xcc', 83: '0xc0ceb%0xec', 82: '0xe00%0xce', 67: '0xcc0e%0xcb', 85: '0xcee0%0xeb', 97: '0xceec%0xeb', 99: '0xcceb%0xee', 117: '0xcc0b%0xce', 100: '0xee0%0xce', 111: '0xeeb%0xce', 114: '0xeee%0xce', 116: '0xe00%0xcc', 42: '0xeeee%0xec', 127: '0xe0b%0xcc', 93: '0xe0b%0xce', 70: '0xccce%0xee', 55: '0xe0b%0xec', 71: '0xe0c%0xeb', 56: '0xe0c%0xec', 73: '0xe0e%0xeb', 58: '0xe0e%0xec', 106: '0xcc00%0xce', 88: '0xcce0%0xee', 118: '0xece%0xcc', 102: '0xcc00%0xee', 104: '0xec0%0xcc', 115: '0xecb%0xcc', 74: '0xe0cc%0xce', 86: '0xc0cc%0xece', 40: '0xe0e0%0xcc', 72: '0xec0e%0xce', 98: '0xc0c0e%0xec', 109: '0xc0ccb%0xce', 103: '0xcccb%0xce', 87: '0xe00b%0xce', 54: '0xe0ee%0xcc', 90: '0xc0cc%0xee', 57: '0xccee%0xeb', 84: '0xc0c00%0xec', 95: '0xc0c0b%0xec', 101: '0xe0ce%0xcb', 105: '0xe0eb%0xce', 113: '0xcc0b%0xee', 121: '0xc0cb%0xce', 89: '0xc0cb%0xee', 125: '0xec00%0xcb'}
dict_cde0 = {0: '0x0%0xe', 12: '0xc%0xe', 1: '0xd%0xc', 13: '0xd%0xe', 2: '0xe%0xc', 14: '0xe%0xee', 10: '0xc0%0xe', 9: '0xcc%0xd', 8: '0xcc%0xe', 11: '0xce%0xd', 4: '0xc0c%0xe', 16: '0xc0c%0xec', 3: '0xe0%0xd', 28: '0xe0e%0xee', 15: '0xccec%0xc0d', 5: '0xc0d%0xe', 29: '0xe00%0xed', 17: '0xc0d%0xec', 6: '0xc00%0xe', 30: '0xec%0xce', 18: '0xe0%0xce', 32: '0xe0%0xc0', 20: '0xe0%0xcc', 19: '0xe0%0xcd', 44: '0xec%0xc0', 31: '0xec%0xcd', 45: '0xed%0xc0', 33: '0xed%0xcc', 46: '0xee%0xc0', 34: '0xee%0xcc', 24: '0xc0c%0xcc', 25: '0xc0d%0xcc', 26: '0xc0e%0xcc', 7: '0xce0%0xd', 64: '0xc000%0xec', 48: '0xc00cc%0xec', 52: '0xc0e0%0xec', 51: '0xcccc%0xed', 50: '0xc00ce%0xec', 36: '0xcccc%0xec', 35: '0xc00ce%0xed', 76: '0xc00c%0xec', 60: '0xc0ecc%0xee', 40: '0xe0e0%0xcc', 22: '0xc0ee%0xcc', 63: '0xce0c%0xcd', 62: '0xe0c0%0xce', 47: '0xc00cd%0xee', 77: '0xc00d%0xec', 61: '0xc0c0c%0xcd', 41: '0xe0c%0xed', 37: '0xcccd%0xec', 23: '0xcc0e0%0xcd', 65: '0xc0ed%0xec', 49: '0xc00cd%0xec', 78: '0xc00e%0xec', 42: '0xeeee%0xec', 27: '0xe0d%0xee', 38: '0xccce%0xec', 66: '0xc0ee%0xec', 80: '0xecc%0xce', 68: '0xec0%0xce', 92: '0xc0ce%0xee', 93: '0xc000%0xed', 81: '0xecd%0xce', 94: '0xe0c%0xce', 82: '0xe00%0xce', 96: '0xe0e%0xce', 84: '0xc0c00%0xec', 67: '0xc00ee%0xed', 108: '0xc00c%0xe0', 79: '0xc00ed%0xee', 109: '0xc00d%0xe0', 97: '0xc0c0d%0xec', 110: '0xc00e%0xe0', 98: '0xc0c0e%0xec', 116: '0xe00%0xcc', 99: '0xe00%0xcd', 111: '0xe0c%0xcd', 56: '0xe0c%0xec', 112: '0xeec%0xce', 95: '0xe0d%0xce', 57: '0xe0d%0xec', 113: '0xe0e%0xcd', 58: '0xe0e%0xec', 43: '0xe0e%0xed', 104: '0xec0%0xcc', 86: '0xc0cc%0xece', 117: '0xecd%0xcc', 118: '0xece%0xcc', 100: '0xee0%0xce', 120: '0xcc0e%0xce', 102: '0xcc00%0xee', 114: '0xeee%0xce', 115: '0xcc0d%0xee', 124: '0xc000%0xee', 90: '0xc0cc%0xee', 105: '0xc00c%0xed', 103: '0xcce00%0xcd', 106: '0xcc00%0xce', 107: '0xc00e%0xed', 87: '0xc0c0%0xecd', 74: '0xe0cc%0xce', 122: '0xc0cc%0xce', 73: '0xe0ecc%0xed', 72: '0xec0e%0xce', 123: '0xc0cd%0xce', 91: '0xc0cd%0xee', 75: '0xe0cd%0xce', 101: '0xcced%0xee', 88: '0xcce0%0xee', 126: '0xc0c0e%0xce', 89: '0xcecc%0xed', 119: '0xcc0d%0xce', 21: '0xc0ed%0xcc', 54: '0xe0ee%0xcc', 39: '0xccc0%0xed', 69: '0xcccd%0xee', 70: '0xccce%0xee', 53: '0xccce%0xed', 55: '0xee0c%0xcd', 121: '0xce0d%0xec', 85: '0xccee%0xed', 71: '0xcce0%0xed', 83: '0xccec%0xed', 125: '0xc0c0d%0xce', 127: '0xe0cce%0xcd', 59: '0xcec0c%0xed'}
dict_even = {0: '0x0%0xe', 2: '0xe%0xc', 4: '0xc0c%0xe', 6: '0xc00%0xe', 8: '0xcc%0xe', 1: '0xc%0xb', 3: '0xe%0xb', 5: '0xc0%0xb', 11: '0xb%0xe', 12: '0xc%0xe', 13: '0xd%0xe', 14: '0xe%0xee', 7: '0xcb%0xe', 15: '0xf%0xee', 10: '0xc0%0xe', 32: '0xe0%0xc0', 34: '0xee%0xcc', 36: '0xcccc%0xec', 38: '0xccce%0xec', 40: '0xe0e0%0xcc', 9: '0xcc%0xf', 43: '0xeb%0xc0', 44: '0xec%0xc0', 45: '0xed%0xc0', 46: '0xee%0xc0', 47: '0xef%0xc0', 30: '0xec%0xce', 28: '0xe0e%0xee', 26: '0xc0e%0xcc', 24: '0xc0c%0xcc', 21: '0xe0%0xcb', 20: '0xe0%0xcc', 19: '0xe0%0xcd', 18: '0xe0%0xce', 17: '0xe0%0xcf', 64: '0xc000%0xec', 23: '0xc0b%0xcc', 22: '0xc0ee%0xcc', 66: '0xc0ee%0xec', 25: '0xc0d%0xcc', 68: '0xec0%0xce', 27: '0xc00%0xcb', 70: '0xccce%0xee', 29: '0xeb%0xce', 72: '0xec0e%0xce', 37: '0xc000%0xeb', 35: '0xee%0xcb', 31: '0xeb%0xcc', 75: '0xc00b%0xec', 33: '0xec%0xcb', 76: '0xc00c%0xec', 77: '0xe0c%0xcf', 78: '0xc00e%0xec', 39: '0xc0c%0xcb', 79: '0xe0e%0xcf', 16: '0xc0c%0xec', 96: '0xe0e%0xce', 98: '0xc0c0e%0xec', 100: '0xee0%0xce', 102: '0xcc00%0xee', 104: '0xec0%0xcc', 41: '0xc0e%0xcb', 107: '0xc00b%0xe0', 42: '0xeeee%0xec', 108: '0xc00c%0xe0', 109: '0xc00d%0xe0', 110: '0xc00e%0xe0', 111: '0xe0c%0xcd', 62: '0xe0c0%0xce', 60: '0xc0ecc%0xee', 58: '0xe0e%0xec', 56: '0xe0c%0xec', 53: '0xcc00%0xcb', 52: '0xc0e0%0xec', 51: '0xc00e%0xeb', 50: '0xc00ce%0xec', 49: '0xc00c%0xeb', 55: '0xe0b%0xec', 54: '0xe0ee%0xcc', 57: '0xe0d%0xec', 59: '0xe00%0xeb', 61: '0xc0ee%0xcb', 69: '0xcccd%0xee', 67: '0xc0ef%0xec', 63: '0xc0eb%0xec', 65: '0xe00%0xcf', 71: '0xe0c%0xeb', 48: '0xc00cc%0xec', 80: '0xecc%0xce', 74: '0xe0cc%0xce', 82: '0xe00%0xce', 84: '0xc0c00%0xec', 73: '0xe0e%0xeb', 86: '0xc0cc%0xece', 88: '0xcce0%0xee', 91: '0xc0cd%0xee', 89: '0xc0cb%0xee', 87: '0xcccc%0xef', 85: '0xccee%0xed', 83: '0xecf%0xce', 92: '0xc0ce%0xee', 90: '0xc0cc%0xee', 81: '0xecd%0xce', 93: '0xe0b%0xce', 94: '0xe0c%0xce', 95: '0xe0d%0xce', 101: '0xcced%0xee', 99: '0xe00%0xcd', 97: '0xe0f%0xce', 103: '0xcccb%0xce', 105: '0xc00c%0xed', 106: '0xcc00%0xce', 112: '0xeec%0xce', 114: '0xeee%0xce', 116: '0xe00%0xcc', 118: '0xece%0xcc', 120: '0xcc0e%0xce', 123: '0xc0cd%0xce', 121: '0xc0cb%0xce', 119: '0xecf%0xcc', 117: '0xecd%0xcc', 115: '0xecb%0xcc', 124: '0xc000%0xee', 122: '0xc0cc%0xce', 113: '0xe0e%0xcd', 125: '0xc0cf%0xce', 126: '0xc0c0e%0xce', 127: '0xe0b%0xcc'}
def compile_bce0(s, remain_set="exc('%0)b,"): # replace other characters by "bce0,"
s = s.replace("%", "%%")
postfix = []
remove_set = {chr(c) for c in range(128)} - set(remain_set)
while True:
for c in s:
if c in remove_set:
s = s.replace(c, "%c", 1)
postfix.append(dict_bce0[ord(c)])
break
else:
break
return s, f'({",".join(postfix)})'
def compile_b_comma(s): # mapping ["b" => "%(c)c"], ["," => "%(e)c"]
s = s.replace("%", "%%").replace("b", "%(c)c").replace(",", "%(e)c")
return s, f"dict((('c','%c'%({dict_bce0[ord('b')]})),('e','%c'%({dict_bce0[ord(',')]}))))"
def compile_comma(s): # %(',',)*(num)
num = s.count(",")
s = s.replace("%", "%%").replace(",", "%c")
return s, f"('%c'%({dict_bce0[ord(',')]}),)*{dict_ce0[num]}"
def compile_final(s): # replace any other characters
postfix = ""
remove_set = [chr(c) for c in range(128) if chr(c) not in "exc('%0)"]
while True:
for c in remove_set:
if c in s:
s = s.replace("%", "%%").replace(c, "%c", 1)
postfix = f"%({dict_ce0[ord(c)]}){postfix}"
break
else:
break
return s, postfix