-
Notifications
You must be signed in to change notification settings - Fork 0
/
brainfuck.py
305 lines (305 loc) · 24.2 KB
/
brainfuck.py
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
#-*- coding:utf-8 -*-
#python2.7.18_brainfuck
__all__=["\x69\x6e\x70\x75\x74\x65\x72\x72\x6f\x72","\x64\x61\x74\x61\x65\x72\x72\x6f\x72","\x6d\x6f\x76\x65\x65\x72\x72\x6f\x72","\x6c\x6f\x6f\x70\x65\x72\x72\x6f\x72","\x5f","\x67\x65\x74\x63\x68","\x70\x75\x74\x63\x68","\x73\x74\x72\x5f\x63\x6f\x6d\x70\x69\x6c\x65","\x66\x69\x6c\x65\x5f\x63\x6f\x6d\x70\x69\x6c\x65","\x73\x74\x72\x5f\x72\x75\x6e","\x66\x69\x6c\x65\x5f\x72\x75\x6e"]
class inputerror(Exception):pass
class dataerror(Exception):pass
class moveerror(Exception):pass
class looperror(Exception):pass
from msvcrt import getch,putch
_=frozenset(("\x2b","\x2d","\x3c","\x3e","\x5b","\x5d","\x2c","\x2e"))
def str_compile(code=""):
if type(code)==str:return "".join((a for a in code if a in _))
else:raise inputerror
def file_compile(input_file="",output_file=""):
if type(input_file)==type(output_file)==str:
input_file=open(input_file,"\x72\x62")
output_file=open(output_file,"\x77\x62")
a=input_file.read(1)
while a!="":
if a in _:
output_file.write(a)
output_file.flush()
a=input_file.read(1)
input_file.close()
output_file.close()
else:raise inputerror
def str_run(code="",input=getch,output=putch,add=True,sub=True,left=True,right=True,ret=False):
if type(code)==str and "\x5f\x5f\x63\x61\x6c\x6c\x5f\x5f" in dir(input) and "\x5f\x5f\x63\x61\x6c\x6c\x5f\x5f" in dir(output) and type(add)==type(sub)==type(left)==type(right)==type(ret)==bool:
length=len(code)
code_pointer=0
loop_level=0
data_pointer=0
level_temp=0
pointer_temp=0
data=[0]
loop_data=[]
while code_pointer<length:
if code[code_pointer]=="\x2b":
if data[data_pointer]==255:
if add:data[data_pointer]=0
else:raise dataerror("".join(("\x69\x6e\x20\x63\x6f\x64\x65\x5b",str(code_pointer),"\x5d\x2c\x64\x61\x74\x61\x5b",str(data_pointer),"\x5d\x3a\x0d\x0a\x74\x72\x79\x20\x74\x6f\x20\x32\x35\x35\x2b\x31\x2c\x62\x75\x74\x20\x61\x64\x64\x20\x69\x73\x20\x46\x61\x6c\x73\x65")))
else:data[data_pointer]=data[data_pointer]+1
elif code[code_pointer]=="\x2d":
if data[data_pointer]==0:
if sub:data[data_pointer]=255
else:raise dataerror("".join(("\x69\x6e\x20\x63\x6f\x64\x65\x5b",str(code_pointer),"\x5d\x2c\x64\x61\x74\x61\x5b",str(data_pointer),"\x5d\x3a\x0d\x0a\x74\x72\x79\x20\x74\x6f\x20\x30\x2d\x31\x2c\x62\x75\x74\x20\x73\x75\x62\x20\x69\x73\x20\x46\x61\x6c\x73\x65")))
else:data[data_pointer]=data[data_pointer]-1
elif code[code_pointer]=="\x3c":
if data_pointer==0:
if left:data=[0]+data
else:raise moveerror("".join(("\x69\x6e\x20\x63\x6f\x64\x65\x5b",str(code_pointer),"\x5d\x2c\x64\x61\x74\x61\x5b",str(data_pointer),"\x5d\x3a\x0d\x0a\x74\x72\x79\x20\x74\x6f\x20\x64\x61\x74\x61\x5f\x70\x6f\x69\x6e\x74\x65\x72\x2d\x31\x2c\x62\x75\x74\x20\x64\x61\x74\x61\x5f\x70\x6f\x69\x6e\x74\x65\x72\x20\x69\x73\x20\x30\x20\x61\x6e\x64\x20\x6c\x65\x66\x74\x20\x69\x73\x20\x46\x61\x6c\x73\x65")))
else:data_pointer=data_pointer-1
elif code[code_pointer]=="\x3e":
data_pointer=data_pointer+1
if data_pointer==len(data):
if right:data.append(0)
else:raise moveerror("".join(("\x69\x6e\x20\x63\x6f\x64\x65\x5b",str(code_pointer),"\x5d\x2c\x64\x61\x74\x61\x5b",str(data_pointer),"\x5d\x3a\x0d\x0a\x74\x72\x79\x20\x74\x6f\x20\x64\x61\x74\x61\x5f\x70\x6f\x69\x6e\x74\x65\x72\x2b\x31\x2c\x62\x75\x74\x20\x64\x61\x74\x61\x5f\x70\x6f\x69\x6e\x74\x65\x72\x20\x69\x73\x20\x65\x6e\x64\x20\x6f\x66\x20\x64\x61\x74\x61\x20\x61\x6e\x64\x20\x72\x69\x67\x68\x74\x20\x69\x73\x20\x46\x61\x6c\x73\x65")))
elif code[code_pointer]=="\x2c":data[data_pointer]=ord(input())
elif code[code_pointer]=="\x2e":output(chr(data[data_pointer]))
elif code[code_pointer]=="\x5b":
loop_level=loop_level+1
level_temp=loop_level
pointer_temp=code_pointer
while loop_level!=0:
if length-code_pointer>1:
code_pointer=code_pointer+1
if code[code_pointer]=="\x5b":loop_level=loop_level+1
elif code[code_pointer]=="\x5d":loop_level=loop_level-1
else:raise looperror("".join(("\x69\x6e\x20\x63\x6f\x64\x65\x5b",str(code_pointer),"\x5d\x2c\x64\x61\x74\x61\x5b",str(data_pointer),"\x5d\x2c\x6c\x6f\x6f\x70\x5f\x6c\x65\x76\x65\x6c\x3d",str(loop_level),"\x3a\x0d\x0a\x6d\x69\x73\x73\x69\x6e\x67\x20\x6c\x6f\x6f\x70\x20\x65\x6e\x64")))
if data[data_pointer]!=0:
loop_level=level_temp
code_pointer=pointer_temp
loop_data.append(code_pointer)
elif code[code_pointer]=="\x5d":
if loop_level==0:raise looperror("".join(("\x69\x6e\x20\x63\x6f\x64\x65\x5b",str(code_pointer),"\x5d\x2c\x64\x61\x74\x61\x5b",str(data_pointer),"\x5d\x2c\x6c\x6f\x6f\x70\x5f\x6c\x65\x76\x65\x6c\x3d",str(loop_level),"\x3a\x0d\x0a\x6d\x69\x73\x73\x69\x6e\x67\x20\x6c\x6f\x6f\x70\x20\x73\x74\x61\x72\x74")))
elif data[data_pointer]==0:
del loop_data[-1]
loop_level=loop_level-1
else:code_pointer=loop_data[-1]
code_pointer=code_pointer+1
if ret:return (data,data_pointer)
else:raise inputerror
def file_run(input_file="",input=getch,output=putch,add=True,sub=True,left=True,right=True,ret=False):
if type(input_file)==str and "\x5f\x5f\x63\x61\x6c\x6c\x5f\x5f" in dir(input) and "\x5f\x5f\x63\x61\x6c\x6c\x5f\x5f" in dir(output) and type(add)==type(sub)==type(left)==type(right)==type(ret)==bool:
input_file=open(input_file,"\x72\x62")
data=[0]
data_pointer=0
loop_level=0
pointer_temp=0
level_temp=0
loop_data=[]
buffer=input_file.read(1)
while buffer!="":
if buffer=="\x2b":
if data[data_pointer]==255:
if add:data[data_pointer]=0
else:raise dataerror("".join(("\x69\x6e\x20\x63\x6f\x64\x65\x5b",str(input_file.tell()-1),"\x5d\x2c\x64\x61\x74\x61\x5b",str(data_pointer),"\x5d\x3a\x0d\x0a\x74\x72\x79\x20\x74\x6f\x20\x32\x35\x35\x2b\x31\x2c\x62\x75\x74\x20\x61\x64\x64\x20\x69\x73\x20\x46\x61\x6c\x73\x65")))
else:data[data_pointer]=data[data_pointer]+1
elif buffer=="\x2d":
if data[data_pointer]==0:
if sub:data[data_pointer]=255
else:raise dataerror("".join(("\x69\x6e\x20\x63\x6f\x64\x65\x5b",str(input_file.tell()-1),"\x5d\x2c\x64\x61\x74\x61\x5b",str(data_pointer),"\x5d\x3a\x0d\x0a\x74\x72\x79\x20\x74\x6f\x20\x30\x2d\x31\x2c\x62\x75\x74\x20\x73\x75\x62\x20\x69\x73\x20\x46\x61\x6c\x73\x65")))
else:data[data_pointer]=data[data_pointer]-1
elif buffer=="\x3c":
if data_pointer==0:
if left:data=[0]+data
else:raise moveerror("".join(("\x69\x6e\x20\x63\x6f\x64\x65\x5b",str(input_file.tell()-1),"\x5d\x2c\x64\x61\x74\x61\x5b",str(data_pointer),"\x5d\x3a\x0d\x0a\x74\x72\x79\x20\x74\x6f\x20\x64\x61\x74\x61\x5f\x70\x6f\x69\x6e\x74\x65\x72\x2d\x31\x2c\x62\x75\x74\x20\x64\x61\x74\x61\x5f\x70\x6f\x69\x6e\x74\x65\x72\x20\x69\x73\x20\x30\x20\x61\x6e\x64\x20\x6c\x65\x66\x74\x20\x69\x73\x20\x46\x61\x6c\x73\x65")))
else:data_pointer=data_pointer-1
elif buffer=="\x3e":
data_pointer=data_pointer+1
if data_pointer==len(data):
if right:data.append(0)
else:raise moveerror("".join(("\x69\x6e\x20\x63\x6f\x64\x65\x5b",str(input_file.tell()-1),"\x5d\x2c\x64\x61\x74\x61\x5b",str(data_pointer),"\x5d\x3a\x0d\x0a\x74\x72\x79\x20\x74\x6f\x20\x64\x61\x74\x61\x5f\x70\x6f\x69\x6e\x74\x65\x72\x2b\x31\x2c\x62\x75\x74\x20\x64\x61\x74\x61\x5f\x70\x6f\x69\x6e\x74\x65\x72\x20\x69\x73\x20\x65\x6e\x64\x20\x6f\x66\x20\x64\x61\x74\x61\x20\x61\x6e\x64\x20\x72\x69\x67\x68\x74\x20\x69\x73\x20\x46\x61\x6c\x73\x65")))
elif buffer=="\x2c":data[data_pointer]=ord(input())
elif buffer=="\x2e":output(chr(data[data_pointer]))
elif buffer=="\x5b":
loop_level=loop_level+1
level_temp=loop_level
pointer_temp=input_file.tell()
while loop_level!=0:
buffer=input_file.read(1)
if buffer=="":raise looperror("".join(("\x69\x6e\x20\x63\x6f\x64\x65\x5b",str(input_file.tell()-1),"\x5d\x2c\x64\x61\x74\x61\x5b",str(data_pointer),"\x5d\x2c\x6c\x6f\x6f\x70\x5f\x6c\x65\x76\x65\x6c\x3d",str(loop_level),"\x3a\x0d\x0a\x6d\x69\x73\x73\x69\x6e\x67\x20\x6c\x6f\x6f\x70\x20\x65\x6e\x64")))
elif buffer=="\x5b":loop_level=loop_level+1
elif buffer=="\x5d":loop_level=loop_level-1
if data[data_pointer]!=0:
loop_level=level_temp
input_file.seek(pointer_temp)
loop_data.append(pointer_temp)
elif buffer=="\x5d":
if loop_level==0:raise looperror("".join(("\x69\x6e\x20\x63\x6f\x64\x65\x5b",str(input_file.tell()-1),"\x5d\x2c\x64\x61\x74\x61\x5b",str(data_pointer),"\x5d\x2c\x6c\x6f\x6f\x70\x5f\x6c\x65\x76\x65\x6c\x3d",str(loop_level),"\x3a\x0d\x0a\x6d\x69\x73\x73\x69\x6e\x67\x20\x6c\x6f\x6f\x70\x20\x73\x74\x61\x72\x74")))
elif data[data_pointer]==0:
del loop_data[-1]
loop_level=loop_level-1
else:input_file.seek(loop_data[-1])
buffer=input_file.read(1)
if ret:return (data,data_pointer)
else:raise inputerror
if __name__=="\x5f\x5f\x6d\x61\x69\x6e\x5f\x5f":
del __all__,str_compile,str_run
from sys import argv,__stdin__,__stdout__
argv=tuple(argv)
__stdin__=__stdin__.readline.__call__
__stdout__=__stdout__.write.__call__
a=len(argv)
if a==1:
del _,file_compile,file_run
buffer=""
code_list=[]
input_list=[]
output_list=[]
loop_data=[]
add=True
sub=True
left=True
right=True
length=0
code_pointer=0
data_pointer=0
loop_level=0
level_temp=0
pointer_temp=0
data=[0]
def a(b):
pointer=level=0
leng=len(b)
while pointer<leng:
if b[pointer]=="\x5b":
level=level+1
while level!=0:
if leng-pointer>1:
pointer=pointer+1
if b[pointer]=="\x5b":level=level+1
elif b[pointer]=="\x5d":level=level-1
else:return False
pointer=pointer+1
return True
__stdout__("\x70\x79\x62\x66\x20\x62\x72\x61\x69\x6e\x66\x75\x63\x6b\x20\x72\x75\x6e\x20\x69\x6e\x20\x70\x79\x74\x68\x6f\x6e\x32\x2e\x37\x2e\x31\x38\x2c\x69\x6e\x70\x75\x74\x20\x22\x2f\x68\x65\x6c\x70\x22\x20\x74\x6f\x20\x67\x65\x74\x20\x68\x65\x6c\x70\x0d\x0a\x3e\x3e\x3e\x20")
while True:
buffer=__stdin__()[:-1:]
if buffer=="\x2f\x68\x65\x6c\x70":__stdout__("\x2f\x2f\x73\x79\x73\x0a\x69\x6e\x70\x75\x74\x20\x22\x2f\x68\x65\x6c\x70\x22\x20\x74\x6f\x20\x67\x65\x74\x20\x68\x65\x6c\x70\x0a\x69\x6e\x70\x75\x74\x20\x22\x2f\x65\x78\x69\x74\x22\x20\x74\x6f\x20\x65\x78\x69\x74\x0a\x2f\x2f\x67\x65\x74\x0a\x69\x6e\x70\x75\x74\x20\x22\x2f\x63\x6f\x64\x65\x22\x20\x74\x6f\x20\x67\x65\x74\x20\x6c\x69\x73\x74\x20\x6f\x66\x20\x63\x6f\x64\x65\x20\x79\x6f\x75\x20\x69\x6e\x70\x75\x74\x0a\x69\x6e\x70\x75\x74\x20\x22\x2f\x69\x6e\x70\x75\x74\x22\x20\x74\x6f\x20\x67\x65\x74\x20\x79\x6f\x75\x72\x20\x69\x6e\x70\x75\x74\x5f\x6c\x69\x73\x74\x20\x6f\x66\x20\x62\x72\x61\x69\x6e\x66\x75\x63\x6b\x0a\x69\x6e\x70\x75\x74\x20\x22\x2f\x6f\x75\x74\x70\x75\x74\x22\x20\x74\x6f\x20\x67\x65\x74\x20\x62\x72\x61\x69\x6e\x66\x75\x63\x6b\x20\x6f\x75\x74\x70\x75\x74\x5f\x6c\x69\x73\x74\x0a\x69\x6e\x70\x75\x74\x20\x22\x2f\x64\x61\x74\x61\x22\x20\x74\x6f\x20\x67\x65\x74\x20\x64\x61\x74\x61\x20\x6f\x66\x20\x62\x72\x61\x69\x6e\x66\x75\x63\x6b\x0a\x69\x6e\x70\x75\x74\x20\x22\x2f\x64\x70\x22\x20\x74\x6f\x20\x67\x65\x74\x20\x64\x61\x74\x61\x5f\x70\x6f\x69\x6e\x74\x65\x72\x20\x6f\x66\x20\x62\x72\x61\x69\x6e\x66\x75\x63\x6b\x0a\x69\x6e\x70\x75\x74\x20\x22\x2f\x6c\x70\x22\x20\x74\x6f\x20\x67\x65\x74\x20\x6c\x6f\x6f\x70\x5f\x6c\x65\x76\x65\x6c\x20\x6f\x66\x20\x62\x72\x61\x69\x6e\x66\x75\x63\x6b\x0a\x69\x6e\x70\x75\x74\x20\x22\x2f\x61\x6c\x6c\x22\x20\x74\x6f\x20\x67\x65\x74\x20\x22\x2f\x63\x6f\x64\x65\x22\x2c\x22\x2f\x69\x6e\x70\x75\x74\x22\x2c\x22\x2f\x6f\x75\x74\x70\x75\x74\x22\x2c\x22\x2f\x64\x61\x74\x61\x22\x2c\x22\x2f\x64\x70\x22\x2c\x22\x2f\x6c\x70\x22\x20\x64\x61\x74\x61\x0a\x2f\x2f\x63\x6c\x65\x61\x72\x0a\x69\x6e\x70\x75\x74\x20\x22\x2f\x63\x6c\x65\x61\x72\x20\x63\x6f\x64\x65\x22\x20\x74\x6f\x20\x63\x6c\x65\x61\x72\x20\x63\x6f\x64\x65\x5f\x6c\x69\x73\x74\x0a\x69\x6e\x70\x75\x74\x20\x22\x2f\x63\x6c\x65\x61\x72\x20\x69\x6e\x70\x75\x74\x22\x20\x74\x6f\x20\x63\x6c\x65\x61\x72\x20\x69\x6e\x70\x75\x74\x5f\x6c\x69\x73\x74\x0a\x69\x6e\x70\x75\x74\x20\x22\x2f\x63\x6c\x65\x61\x72\x20\x6f\x75\x74\x70\x75\x74\x22\x20\x74\x6f\x20\x63\x6c\x65\x61\x72\x20\x6f\x75\x74\x70\x75\x74\x5f\x6c\x69\x73\x74\x0a\x69\x6e\x70\x75\x74\x20\x22\x2f\x63\x6c\x65\x61\x72\x20\x61\x6c\x6c\x22\x20\x74\x6f\x20\x63\x6c\x65\x61\x72\x20\x63\x6f\x64\x65\x5f\x6c\x69\x73\x74\x2c\x69\x6e\x70\x75\x74\x5f\x6c\x69\x73\x74\x2c\x6f\x75\x74\x70\x75\x74\x5f\x6c\x69\x73\x74\x0a\x2f\x2f\x73\x65\x74\x0a\x69\x6e\x70\x75\x74\x20\x22\x2f\x73\x65\x74\x20\x61\x64\x64\x20\x54\x72\x75\x65\x22\x20\x74\x6f\x20\x73\x65\x74\x20\x61\x64\x64\x3d\x54\x72\x75\x65\x0a\x69\x6e\x70\x75\x74\x20\x22\x2f\x73\x65\x74\x20\x61\x64\x64\x20\x46\x61\x6c\x73\x65\x22\x20\x74\x6f\x20\x73\x65\x74\x20\x61\x64\x64\x3d\x46\x61\x6c\x73\x65\x0a\x69\x6e\x70\x75\x74\x20\x22\x2f\x73\x65\x74\x20\x73\x75\x62\x20\x54\x72\x75\x65\x22\x20\x74\x6f\x20\x73\x65\x74\x20\x73\x75\x62\x3d\x54\x72\x75\x65\x0a\x69\x6e\x70\x75\x74\x20\x22\x2f\x73\x65\x74\x20\x73\x75\x62\x20\x46\x61\x6c\x73\x65\x22\x20\x74\x6f\x20\x73\x65\x74\x20\x73\x75\x62\x3d\x46\x61\x6c\x73\x65\x0a\x69\x6e\x70\x75\x74\x20\x22\x2f\x73\x65\x74\x20\x6c\x65\x66\x74\x20\x54\x72\x75\x65\x22\x20\x74\x6f\x20\x73\x65\x74\x20\x6c\x65\x66\x74\x3d\x54\x72\x75\x65\x0a\x69\x6e\x70\x75\x74\x20\x22\x2f\x73\x65\x74\x20\x6c\x65\x66\x74\x20\x46\x61\x6c\x73\x65\x22\x20\x74\x6f\x20\x73\x65\x74\x20\x6c\x65\x66\x74\x3d\x46\x61\x6c\x73\x65\x0a\x69\x6e\x70\x75\x74\x20\x22\x2f\x73\x65\x74\x20\x72\x69\x67\x68\x74\x20\x54\x72\x75\x65\x22\x20\x74\x6f\x20\x73\x65\x74\x20\x72\x69\x67\x68\x74\x3d\x54\x72\x75\x65\x0a\x69\x6e\x70\x75\x74\x20\x22\x2f\x73\x65\x74\x20\x72\x69\x67\x68\x74\x20\x46\x61\x6c\x73\x65\x22\x20\x74\x6f\x20\x73\x65\x74\x20\x72\x69\x67\x68\x74\x3d\x46\x61\x6c\x73\x65\x0d\x0a\x69\x6e\x70\x75\x74\x20\x22\x2f\x72\x65\x73\x65\x74\x22\x20\x74\x6f\x20\x72\x65\x73\x65\x74\x20\x61\x6c\x6c\x20\x76\x61\x6c\x75\x65\x73\x0d\x0a")
elif buffer=="\x2f\x65\x78\x69\x74":exit()
elif buffer=="\x2f\x72\x65\x73\x65\x74":
buffer=""
code_list=[]
input_list=[]
output_list=[]
loop_data=[]
add=True
sub=True
left=True
right=True
length=0
code_pointer=0
data_pointer=0
loop_level=0
level_temp=0
pointer_temp=0
data=[0]
elif buffer=="\x2f\x63\x6f\x64\x65":__stdout__("".join((str(code_list),"\x0d\x0a")))
elif buffer=="\x2f\x69\x6e\x70\x75\x74":__stdout__("".join((str(input_list),"\x0d\x0a")))
elif buffer=="\x2f\x6f\x75\x74\x70\x75\x74":__stdout__("".join((str(output_list),"\x0d\x0a")))
elif buffer=="\x2f\x64\x61\x74\x61":__stdout__("".join((str(data),"\x0d\x0a")))
elif buffer=="\x2f\x64\x70":__stdout__("".join((str(data_pointer),"\x0d\x0a")))
elif buffer=="\x2f\x6c\x70":__stdout__("".join((str(loop_level),"\x0d\x0a")))
elif buffer=="\x2f\x61\x6c\x6c":__stdout__("".join((str(code_list),"\x0d\x0a",str(input_list),"\x0d\x0a",str(output_list),"\x0d\x0a",str(data),"\x0d\x0a",str(data_pointer),"\x0d\x0a",str(loop_level),"\x0d\x0a")))
elif buffer=="\x2f\x63\x6c\x65\x61\x72\x20\x63\x6f\x64\x65":code_list=[]
elif buffer=="\x2f\x63\x6c\x65\x61\x72\x20\x69\x6e\x70\x75\x74":input_list=[]
elif buffer=="\x2f\x63\x6c\x65\x61\x72\x20\x6f\x75\x74\x70\x75\x74":output_list=[]
elif buffer=="\x2f\x63\x6c\x65\x61\x72\x20\x61\x6c\x6c":
code_list=[]
input_list=[]
output_list=[]
elif buffer=="\x2f\x73\x65\x74\x20\x61\x64\x64\x20\x54\x72\x75\x65":add=True
elif buffer=="\x2f\x73\x65\x74\x20\x61\x64\x64\x20\x46\x61\x6c\x73\x65":add=False
elif buffer=="\x2f\x73\x65\x74\x20\x73\x75\x62\x20\x54\x72\x75\x65":sub=True
elif buffer=="\x2f\x73\x65\x74\x20\x73\x75\x62\x20\x46\x61\x6c\x73\x65":sub=False
elif buffer=="\x2f\x73\x65\x74\x20\x6c\x65\x66\x74\x20\x54\x72\x75\x65":left=True
elif buffer=="\x2f\x73\x65\x74\x20\x6c\x65\x66\x74\x20\x46\x61\x6c\x73\x65":left=False
elif buffer=="\x2f\x73\x65\x74\x20\x72\x69\x67\x68\x74\x20\x54\x72\x75\x65":right=True
elif buffer=="\x2f\x73\x65\x74\x20\x72\x69\x67\x68\x74\x20\x46\x61\x6c\x73\x65":right=False
else:
while True:
if a(buffer):break
else:
__stdout__("\x2e\x2e\x2e\x20")
buffer="".join((buffer,__stdin__()[:-1:]))
code_list.append(buffer)
length=len(buffer)
while code_pointer<length:
if buffer[code_pointer]=="\x2b":
if data[data_pointer]==255:
if add:data[data_pointer]=0
else:__stdout__("".join(("\x64\x61\x74\x61\x65\x72\x72\x6f\x72\x3a\x20\x69\x6e\x20\x63\x6f\x64\x65\x5b",str(code_pointer),"\x5d\x2c\x64\x61\x74\x61\x5b",str(data_pointer),"\x5d\x3a\x0d\x0a\x74\x72\x79\x20\x74\x6f\x20\x32\x35\x35\x2b\x31\x2c\x62\x75\x74\x20\x61\x64\x64\x20\x69\x73\x20\x46\x61\x6c\x73\x65\x0d\x0a")))
else:data[data_pointer]=data[data_pointer]+1
elif buffer[code_pointer]=="\x2d":
if data[data_pointer]==0:
if sub:data[data_pointer]=255
else:__stdout__("".join(("\x64\x61\x74\x61\x65\x72\x72\x6f\x72\x3a\x20\x69\x6e\x20\x63\x6f\x64\x65\x5b",str(code_pointer),"\x5d\x2c\x64\x61\x74\x61\x5b",str(data_pointer),"\x5d\x3a\x0d\x0a\x74\x72\x79\x20\x74\x6f\x20\x30\x2d\x31\x2c\x62\x75\x74\x20\x73\x75\x62\x20\x69\x73\x20\x46\x61\x6c\x73\x65\x0d\x0a")))
else:data[data_pointer]=data[data_pointer]-1
elif buffer[code_pointer]=="\x3c":
if data_pointer==0:
if left:data=[0]+data
else:__stdout__("".join(("\x6d\x6f\x76\x65\x65\x72\x72\x6f\x72\x3a\x20\x69\x6e\x20\x63\x6f\x64\x65\x5b",str(code_pointer),"\x5d\x2c\x64\x61\x74\x61\x5b",str(data_pointer),"\x5d\x3a\x0d\x0a\x74\x72\x79\x20\x74\x6f\x20\x64\x61\x74\x61\x5f\x70\x6f\x69\x6e\x74\x65\x72\x2d\x31\x2c\x62\x75\x74\x20\x64\x61\x74\x61\x5f\x70\x6f\x69\x6e\x74\x65\x72\x20\x69\x73\x20\x30\x20\x61\x6e\x64\x20\x6c\x65\x66\x74\x20\x69\x73\x20\x46\x61\x6c\x73\x65\x0d\x0a")))
else:data_pointer=data_pointer-1
elif buffer[code_pointer]=="\x3e":
data_pointer=data_pointer+1
if data_pointer==len(data):
if right:data.append(0)
else:__stdout__("".join(("\x6d\x6f\x76\x65\x65\x72\x72\x6f\x72\x3a\x20\x69\x6e\x20\x63\x6f\x64\x65\x5b",str(code_pointer),"\x5d\x2c\x64\x61\x74\x61\x5b",str(data_pointer),"\x5d\x3a\x0d\x0a\x74\x72\x79\x20\x74\x6f\x20\x64\x61\x74\x61\x5f\x70\x6f\x69\x6e\x74\x65\x72\x2b\x31\x2c\x62\x75\x74\x20\x64\x61\x74\x61\x5f\x70\x6f\x69\x6e\x74\x65\x72\x20\x69\x73\x20\x65\x6e\x64\x20\x6f\x66\x20\x64\x61\x74\x61\x20\x61\x6e\x64\x20\x72\x69\x67\x68\x74\x20\x69\x73\x20\x46\x61\x6c\x73\x65\x0d\x0a")))
elif buffer[code_pointer]=="\x2c":
input_list.append(ord(getch()))
data[data_pointer]=input_list[-1]
elif buffer[code_pointer]=="\x2e":output_list.append(chr(data[data_pointer]))
elif buffer[code_pointer]=="\x5b":
loop_level=loop_level+1
level_temp=loop_level
pointer_temp=code_pointer
while loop_level!=0:
if length-code_pointer>1:
code_pointer=code_pointer+1
if buffer[code_pointer]=="\x5b":loop_level=loop_level+1
elif buffer[code_pointer]=="\x5d":loop_level=loop_level-1
else:
__stdout__("".join(("\x6c\x6f\x6f\x70\x65\x72\x72\x6f\x72\x3a\x20\x69\x6e\x20\x63\x6f\x64\x65\x5b",str(code_pointer),"\x5d\x2c\x64\x61\x74\x61\x5b",str(data_pointer),"\x5d\x2c\x6c\x6f\x6f\x70\x5f\x6c\x65\x76\x65\x6c\x3d",str(loop_level),"\x3a\x0d\x0a\x6d\x69\x73\x73\x69\x6e\x67\x20\x6c\x6f\x6f\x70\x20\x65\x6e\x64\x0d\x0a")))
break
if data[data_pointer]!=0:
loop_level=level_temp
code_pointer=pointer_temp
loop_data.append(code_pointer)
elif buffer[code_pointer]=="\x5d":
if loop_level==0:__stdout__("".join(("\x6c\x6f\x6f\x70\x65\x72\x72\x6f\x72\x3a\x20\x69\x6e\x20\x63\x6f\x64\x65\x5b",str(code_pointer),"\x5d\x2c\x64\x61\x74\x61\x5b",str(data_pointer),"\x5d\x2c\x6c\x6f\x6f\x70\x5f\x6c\x65\x76\x65\x6c\x3d",str(loop_level),"\x3a\x0d\x0a\x6d\x69\x73\x73\x69\x6e\x67\x20\x6c\x6f\x6f\x70\x20\x73\x74\x61\x72\x74\x0d\x0a")))
elif data[data_pointer]==0:
del loop_data[-1]
loop_level=loop_level-1
else:code_pointer=loop_data[-1]
code_pointer=code_pointer+1
code_pointer=0
__stdout__("\x3e\x3e\x3e\x20")
elif a in (3,4):
if argv[1]=="\x63\x6f\x6d\x70\x69\x6c\x65" and a==3:
del file_run
a=argv[2].split("\x7c")
if len(a)==2:file_compile(a[0],a[1])
else:raise inputerror
elif argv[1]=="\x72\x75\x6e":
del _,file_compile
if a==3:file_run(argv[2])
else:
a=argv[3].split("\x7c")
b=len(a)
def c(_):
if _=="\x54\x72\x75\x65":return True
elif _=="\x46\x61\x6c\x73\x65":return False
else:raise inputerror
if b==1:file_run(argv[2],getch,putch,c(a[0]))
elif b==2:file_run(argv[2],getch,putch,c(a[0]),c(a[1]))
elif b==3:file_run(argv[2],getch,putch,c(a[0]),c(a[1]),c(a[2]))
elif b==4:file_run(argv[2],getch,putch,c(a[0]),c(a[1]),c(a[2]),c(a[3]))
elif b==5:
if a[4]=="\x54\x72\x75\x65":
b=file_run(argv[2],getch,putch,c(a[0]),c(a[1]),c(a[2]),c(a[3]),True)
__stdout__("".join(("\x0d\x0a",str(b[0]),"\x0d\x0a",str(b[1]))))
else:file_run(argv[2],getch,putch,c(a[0]),c(a[1]),c(a[2]),c(a[3]),c(a[4]))
else:raise inputerror
else:raise inputerror
else:raise inputerror