This repository has been archived by the owner on Aug 23, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun_system_functions.py
722 lines (711 loc) · 31.1 KB
/
run_system_functions.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
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
import os
import AFM
import time
import JAPFL
import PAPFL
import HAPFL
import CAPFL
import BAPFL
import DAPFL
import JSAPFL
import KTAPFL
import subprocess
start_time = time.time()
command2 = ''
command = "python runned_code.py"
token_message = ''
token_message2 = ''
token_message3 = ''
token_message4 = ''
programminglanguagefileformat = '.py'
func_mapping_var = {}
func_mapping_var2 = {}
with open('options.txt', 'r') as options_Reader:
options = options_Reader.read()
def normal_function_mapping(code:str,function_mapping_variable:dict):
# sourcery skip: missing-dict-items
lines2 = code.strip().split("""
""")
for s in range(len(lines2)):
for short, full in function_mapping_variable:
lines2[s] = lines2[s].replace(short, full)
return """
""".join(lines2)
def find_between(filepath,first_word, second_word, occurrence):
with open(filepath, 'r') as file:
lines = file.readlines()
file.close()
first_line_number = None
second_line_number = None
count = 0
for i, line in enumerate(lines):
if first_word in line:
count += 1
if count == occurrence:
first_line_number = i
if second_word in line and count == occurrence:
second_line_number = i
break
if first_line_number is not None and second_line_number is not None:
words_between = []
for i in range(first_line_number + 1, second_line_number):
line = lines[i].strip()
words_between.append(lines[i])
return words_between
else:
return [] # If either first_word or second_word is not found in the file or occurrence is not found
def find_between2(code:str,first_word, second_word, occurrence):
lines = code.strip().split("""
""")
first_line_number = None
second_line_number = None
count = 0
for i, line in enumerate(lines):
if first_word in line:
count += 1
if count == occurrence:
first_line_number = i
if second_word in line and count == occurrence:
second_line_number = i
break
if first_line_number is not None and second_line_number is not None:
words_between = []
for i in range(first_line_number + 1, second_line_number):
line = lines[i].strip()
words_between.append(lines[i])
return words_between
else:
return [] # If either first_word or second_word is not found in the file or occurrence is not found
def find_between2_2(code:str,first_word, second_word, occurrence):
lines = code.split("""
""")
first_line_number = None
second_line_number = None
count = 0
for i, line in enumerate(lines):
if first_word in line:
count += 1
if count == occurrence:
first_line_number = i
if second_word in line and count == occurrence:
second_line_number = i
break
if first_line_number is not None and second_line_number is not None:
words_between = []
for i in range(first_line_number + 1, second_line_number):
line = lines[i].strip()
words_between.append(lines[i])
return words_between
else:
return [] # If either first_word or second_word is not found in the file or occurrence is not found
def find_between3(text, firstword, secondword):
start_index = text.find(firstword) + len(firstword)
end_index = text.find(secondword)
if start_index == -1 or end_index == -1:
return None
return text[start_index:end_index]
def list_to_string(lst):
string = r''.join(lst)
return string
def list_to_string2(lst):
string = (r'''
''').join(lst)
return string
def compile(mode:str,file_path:str,thecode:str,programminglanguage:str):
command2 = ''
options_Reader = open('options.txt', 'r')
if thecode == '' and file_path != '':
co = open(file_path,'r')
code = co.read()
co.close()
if thecode != '' and file_path == '':
code = thecode
else:
print('no data')
code = ''
options = options_Reader.read()
SET_NO_STATEMENT_FUNCTION_CALLING = list_to_string(find_between2(options, '$<set no statement function calling>','/set no statement function calling>$', 1))
options_Reader.close()
prt = ''
prt2 = ''
prt3 = ''
prt4 = ''
prt5 = ''
prt6 = ''
prt7 = ''
prt8 = ''
start_time = time.time()
x = int(time.strftime('%Y%d%d%H%M%S'))
command = "python runned_code.py"
token_message = ''
token_message2 = ''
token_message3 = ''
token_message4 = ''
programminglanguagefileformat = '.py'
func_mapping_var = {}
func_mapping_var2 = {}
if programminglanguage == 'python':
func_mapping_var = PAPFL.func_mapping.items()
func_mapping_var2 = PAPFL.func_mapping.keys()
if programminglanguage == 'C' or programminglanguage == 'c':
func_mapping_var = CAPFL.func_mapping.items()
func_mapping_var2 = CAPFL.func_mapping.keys()
if programminglanguage == 'java':
func_mapping_var = JAPFL.func_mapping.items()
func_mapping_var2 = JAPFL.func_mapping.keys()
if programminglanguage == 'javascript' or programminglanguage == 'JS':
func_mapping_var = JSAPFL.func_mapping.items()
func_mapping_var2 = JSAPFL.func_mapping.keys()
if programminglanguage == 'batch':
func_mapping_var = BAPFL.func_mapping.items()
func_mapping_var2 = BAPFL.func_mapping.keys()
if programminglanguage == 'kotlin':
func_mapping_var = KTAPFL.func_mapping.items()
func_mapping_var2 = KTAPFL.func_mapping.keys()
if programminglanguage == 'html':
func_mapping_var = HAPFL.func_mapping.items()
func_mapping_var2 = HAPFL.func_mapping.keys()
if programminglanguage == 'data':
func_mapping_var = DAPFL.func_mapping.items()
func_mapping_var2 = DAPFL.func_mapping.keys()
else:
func_mapping_var = PAPFL.func_mapping.items()
func_mapping_var2 = PAPFL.func_mapping.keys()
if programminglanguage != 'python' and programminglanguage != 'C' and programminglanguage != 'c' and programminglanguage != 'java' and programminglanguage != 'javascript' and programminglanguage != 'JS' and programminglanguage != 'batch' and programminglanguage != 'kotlin' and programminglanguage != 'html' and programminglanguage != 'data':
print("unknown programming language")
exit()
lines = code.strip().split('''
''')
a = list(func_mapping_var)
b = list(func_mapping_var2)
for i in range(len(lines)):
if mode == 'f':
data1 = find_between(file_path, b[-7], b[-6], i + 1)
data = list_to_string(data1)
data2 = find_between(file_path, b[-5], b[-4], i + 1)
data_2 = list_to_string(data2)
data_3 = find_between(file_path, b[-7], b[-9], i + 1)
data3 = list_to_string(data_3)
data_4 = find_between(file_path, b[-5], b[-8], i + 1)
data4 = list_to_string(data_4)
if mode == 'c':
data1 = find_between2(code, b[-7], b[-6], i + 1)
data = list_to_string(data1)
data2 = find_between2(code, b[-5], b[-4], i + 1)
data_2 = list_to_string(data2)
data_3 = find_between2(code, b[-7], b[-9], i + 1)
data3 = list_to_string(data_3)
data_4 = find_between2(code, b[-5], b[-8], i + 1)
data4 = list_to_string(data_4)
data1 = find_between2("""
""".join(lines), b[-7], b[-6], i + 1)
data = list_to_string(data1)
data2 = find_between2("""
""".join(lines), b[-5], b[-4], i + 1)
data_2 = list_to_string(data2)
data3 = find_between2("""
""".join(lines), b[-7], b[-9], i + 1)
data_3 = list_to_string(data3)
data4 = find_between2("""
""".join(lines), b[-5], b[-8], i + 1)
data_4 = list_to_string(data4)
semi_fin_lines = code.strip().split("""
""")
code_texted = """
""".join(semi_fin_lines)
goto = find_between3(code_texted, b[-7], b[-6])
goto2 = find_between3(code_texted, b[-5], b[-4])
goto3 = find_between3(code_texted, b[-7], b[-9])
goto4 = find_between3(code_texted, b[-5], b[-8])
if goto == '' or goto == """
""" or goto == '\t' or goto == None:
goto = ''
if goto2 == '' or goto2 == """
""" or goto2 == '\t' or goto2 == None:
goto2 = ''
if goto3 == '' or goto3 == """
""" or goto3 == '\t' or goto3 == None:
goto3 = ''
if goto4 == '' or goto4 == """
""" or goto4 == '\t' or goto4 == None:
goto4 = ''
tokens_shape = f'''$<
{data}
/tokened>$'''
em_tokens_shape = f'''$<
/tokened>$'''
tokens_shape2 = f'''%<
{data_2}
/tokened>%'''
em_tokens_shape2 = f'''%<
/tokened>%'''
function_shape = f'''$<
{data_3}
/function>$'''
em_function_shape = f'''$<
/function>$'''
function_shape2 = f'''%<
{data_4}
/function>%'''
em_function_shape2 = f'''%<
/function>%'''
if programminglanguage == 'data':
prt = AFM.parser.parse(data)
prt2 = AFM.parser.parse(goto)
prt3 = AFM.parser.parse(data_2)
prt4 = AFM.parser.parse(goto2)
prt5 = normal_function_mapping(data_3, func_mapping_var)# type: ignore
prt6 = normal_function_mapping(goto3, func_mapping_var)# type: ignore
prt7 = normal_function_mapping(data_4, func_mapping_var)# type: ignore
prt8 = normal_function_mapping(goto4, func_mapping_var)# type: ignore
if programminglanguage == 'python':
prt = f'print("{AFM.parser.parse(data)}")'
prt2 = f'print("{AFM.parser.parse(goto)}")'
prt3 = f'{AFM.parser.parse(data_2)}'
prt4 = f'{AFM.parser.parse(goto2)}'
prt5 = f'print("{normal_function_mapping(data_3, func_mapping_var)}")'# type: ignore
prt6 = f'print("{normal_function_mapping(goto3, func_mapping_var)}")'# type: ignore
prt7 = f'{normal_function_mapping(data_4, func_mapping_var)}'# type: ignore
prt8 = f'{normal_function_mapping(goto4, func_mapping_var)}'# type: ignore
token_message = '#empty tokened function $'
token_message2 = '#empty tokened function %'
token_message3 = '#empty function $'
token_message4 = '#empty function %'
if programminglanguage == 'C' or programminglanguage == 'c':
prt = f'printf("{AFM.parser.parse(data)}");'
prt2 = f'printf("{AFM.parser.parse(goto)}");'
prt3 = f'{AFM.parser.parse(data_2)}'
prt4 = f'{AFM.parser.parse(goto2)}'
prt5 = f'printf("{normal_function_mapping(data_3, func_mapping_var)}");'# type: ignore
prt6 = f'printf("{normal_function_mapping(goto3, func_mapping_var)}");'# type: ignore
prt7 = f'{normal_function_mapping(data_4, func_mapping_var)}'# type: ignore
prt8 = f'{normal_function_mapping(goto4, func_mapping_var)}'# type: ignore
token_message = '//empty tokened function $'
token_message2 = '//empty tokened function %'
token_message3 = '//#empty function $'
token_message4 = '//#empty function %'
if programminglanguage == 'java':
prt = f'System.out.println("{AFM.parser.parse(data)}");'
prt2 = f'System.out.println("{AFM.parser.parse(goto)}");'
prt3 = f'{AFM.parser.parse(data_2)}'
prt4 = f'{AFM.parser.parse(goto2)}'
prt5 = f'System.out.println("{normal_function_mapping(data_3, func_mapping_var)}");'# type: ignore
prt6 = f'System.out.println("{normal_function_mapping(goto3, func_mapping_var)}");'# type: ignore
prt7 = f'{normal_function_mapping(data_4, func_mapping_var)}' # type: ignore
prt8 = f'{normal_function_mapping(goto4, func_mapping_var)}'# type: ignore
token_message = '//empty tokened function $'
token_message2 = '//empty tokened function %'
token_message3 = '//#empty function $'
token_message4 = '//#empty function %'
if programminglanguage == 'javascript' or programminglanguage == 'JS':
prt = f'console.log("{AFM.parser.parse(data)}")'
prt2 = f'console.log("{AFM.parser.parse(goto)}")'
prt3 = f'{AFM.parser.parse(data_2)}'
prt4 = f'{AFM.parser.parse(goto2)}'
prt5 = f'console.log("{normal_function_mapping(data_3, func_mapping_var)}")'# type: ignore
prt6 = f'console.log("{normal_function_mapping(goto3, func_mapping_var)}")'# type: ignore
prt7 = f'{normal_function_mapping(data_4, func_mapping_var)}'# type: ignore
prt8 = f'{normal_function_mapping(goto4, func_mapping_var)}'# type: ignore
token_message = '//empty tokened function $'
token_message2 = '//empty tokened function %'
token_message3 = '//empty function $'
token_message4 = '//empty function %'
if programminglanguage == 'batch':
prt = f'echo {AFM.parser.parse(data)}'
prt2 = f'echo {AFM.parser.parse(goto)}'
prt3 = f'{AFM.parser.parse(data_2)}'
prt4 = f'{AFM.parser.parse(goto2)}'
prt5 = f'echo {normal_function_mapping(data_3, func_mapping_var)}'# type: ignore
prt6 = f'echo {normal_function_mapping(goto3, func_mapping_var)}'# type: ignore
prt7 = f'{normal_function_mapping(data_4, func_mapping_var)}'# type: ignore
prt8 = f'{normal_function_mapping(goto4, func_mapping_var)}'# type: ignore
token_message = 'echo empty tokened function $'
token_message2 = 'echo empty tokened function %'
token_message3 = 'echo empty function $'
token_message4 = 'echo empty function %'
if programminglanguage == 'kotlin':
prt = f'println("{AFM.parser.parse(data)}")'
prt2 = f'println("{AFM.parser.parse(goto)}")'
prt3 = f'{AFM.parser.parse(data_2)}'
prt4 = f'{AFM.parser.parse(goto2)}'
prt5 = f'println("{normal_function_mapping(data_3, func_mapping_var)}")'# type: ignore
prt6 = f'println("{normal_function_mapping(goto3, func_mapping_var)}")'# type: ignore
prt7 = f'{normal_function_mapping(data_4, func_mapping_var)}'# type: ignore
prt8 = f'{normal_function_mapping(goto4, func_mapping_var)}'# type: ignore
token_message = '//empty tokened function $'
token_message2 = '//empty tokened function %'
token_message3 = '//empty function $'
token_message4 = '//empty function %'
if programminglanguage == 'html':
prt = f'<p>{AFM.parser.parse(data)}</p>'
prt2 = f'<p>{AFM.parser.parse(goto)}</p>'
prt3 = f'{AFM.parser.parse(data_2)}'
prt4 = f'{AFM.parser.parse(goto2)}'
prt5 = f'<p>{normal_function_mapping(data_3, func_mapping_var)}</p>'# type: ignore
prt6 = f'<p>{normal_function_mapping(goto3, func_mapping_var)}</p>'# type: ignore
prt7 = f'{normal_function_mapping(data_4, func_mapping_var)}'# type: ignore
prt8 = f'{normal_function_mapping(goto4, func_mapping_var)}'# type: ignore
token_message = '//empty tokened function $'
token_message2 = '//empty tokened function %'
token_message3 = '//empty function $'
token_message4 = '//empty function %'
if programminglanguage != 'python' and programminglanguage != 'C' and programminglanguage != 'c' and programminglanguage != 'java' and programminglanguage != 'javascript' and programminglanguage != 'JS' and programminglanguage != 'batch' and programminglanguage != 'kotlin' and programminglanguage != 'html' and programminglanguage != 'data':
print("unknown programming language")
exit()
if data != '' and data != '''
''' and data != '\t':
codes = code_texted.replace(tokens_shape, prt)
if f'{b[-7]}{goto}{b[-6]}' in code_texted:
codes = code_texted.replace(f'{b[-7]}{goto}{b[-6]}', prt2)
else:
codes = code_texted.replace(em_tokens_shape, token_message)
semi_fin_lines2 = codes.strip().split("""
""")
code_texted2 = """
""".join(semi_fin_lines2)
if data_2 != '' and data_2 != '''
''' and data_2 != '\t':
codes2 = code_texted2.replace(tokens_shape2, prt3)
if f'{b[-5]}{goto2}{b[-4]}' in code_texted2:
codes2 = code_texted2.replace(f'{b[-5]}{goto2}{b[-4]}', prt4)
else:
codes2 = code_texted2.replace(em_tokens_shape2, token_message2)
fin_lines = codes2.strip().split("""
""")
code_texted3 = """
""".join(fin_lines)
if data_3 != '' and data_3 != '''
''' and data_3 != '\t':
if SET_NO_STATEMENT_FUNCTION_CALLING == 'False':
codes3 = code_texted3.replace(function_shape, prt5)
else:
lines = code_texted3.strip().split("""
""")
for i in range(len(lines)):
for short, full in func_mapping_var:
lines[i] = lines[i].replace(short, full)
codes3 = """
""".join(lines)
if f'{b[-7]}{goto3}{b[-9]}' in code_texted3:
if SET_NO_STATEMENT_FUNCTION_CALLING == 'False':
codes3 = code_texted3.replace(f'{b[-7]}{goto3}{b[-9]}', prt6)
else:
lines = code_texted3.strip().split("""
""")
for i in range(len(lines)):
for short, full in func_mapping_var:
lines[i] = lines[i].replace(short, full)
codes3 = """
""".join(lines)
else:
if SET_NO_STATEMENT_FUNCTION_CALLING == 'False':
codes3 = code_texted3.replace(em_function_shape, token_message3)
else:
lines = code_texted3.strip().split("""
""")
for i in range(len(lines)):
for short, full in func_mapping_var:
lines[i] = lines[i].replace(short, full)
codes3 = """
""".join(lines)
fin_lines2 = codes3.strip().split("""
""")
code_texted4 = """
""".join(fin_lines2)
if data_4 != '' and data_4 != '''
''' and data_4 != '\t':
if SET_NO_STATEMENT_FUNCTION_CALLING == 'False':
codes4 = code_texted4.replace(function_shape2, prt7)
else:
lines = code_texted4.strip().split("""
""")
print(lines)
for i in range(len(lines)):
for short, full in func_mapping_var:
lines[i] = lines[i].replace(short, full)
codes4 = """
""".join(lines)
if f'{b[-5]}{goto4}{b[-8]}' in code_texted4:
if SET_NO_STATEMENT_FUNCTION_CALLING == 'False':
codes4 = code_texted4.replace(f'{b[-5]}{goto4}{b[-8]}', prt8)
else:
lines = code_texted4.strip().split("""
""")
for i in range(len(lines)):
for short, full in func_mapping_var:
lines[i] = lines[i].replace(short, full)
codes4 = """
""".join(lines)
else:
if SET_NO_STATEMENT_FUNCTION_CALLING == 'False':
codes4 = code_texted4.replace(em_function_shape2, token_message4)
else:
lines = code_texted4.strip().split("""
""")
for i in range(len(lines)):
for short, full in func_mapping_var:
lines[i] = lines[i].replace(short, full)
codes4 = """
""".join(lines)
fin_lines3 = codes4.strip().split("""
""")
codee2 = """
""".join(fin_lines3)
return codee2
def runner(code:str,programminglanguage:str,CAROCO:int,PRDF:str='',parallelrun:bool=False,showrunmessage:bool=True,showmessageshowingwarnings:bool=False,returned:bool=False,datalogfilename:str=''):
global programminglanguagefileformat,command,command2
if programminglanguage == 'data':
iD = open(datalogfilename,'w')
iD.write('')
iD.close()
DLA = open(datalogfilename,'w')
DLA.write(code)
DLA.close()
if programminglanguage == 'python':
if parallelrun == True:
command2 = f'python {PRDF}'
pass
if programminglanguage == 'C' or programminglanguage == 'c':
programminglanguagefileformat = '.c'
if CAROCO == 1:
command = "gcc runned_code.c & a.exe"
if CAROCO == 2:
command = "gcc runned_code.c"
if CAROCO == 1 and parallelrun == True:
command2 = f'gcc {PRDF} & a.exe'
if CAROCO == 2 and parallelrun == True:
command2 = "gcc runned_code.c"
if CAROCO != 1 and CAROCO != 2:
print('the value of CAROCO perimeter it is out of range or is not a integer value')
exit()
if programminglanguage == 'batch':
programminglanguagefileformat = '.bat'
command = "runned_code.bat"
if parallelrun == True:
command2 = f'{PRDF}'
if programminglanguage == 'java':
programminglanguagefileformat = '.java'
command = "java runned_code.java"
if parallelrun == True:
command2 = f"java {PRDF}"
if programminglanguage == 'javascript' or programminglanguage == 'JS':
programminglanguagefileformat = '.js'
command = "node runned_code.js"
if parallelrun == True:
command2 = f"node {PRDF}"
if programminglanguage == 'html':
programminglanguagefileformat = '.html'
command = "runned_code.html"
if parallelrun == True:
command2 = f"{PRDF}"
if programminglanguage == 'kotlin':
programminglanguagefileformat = '.kt'
if CAROCO == 1:
command = "kotlinc runned_code.kt & kotlin Runned_codeKT.class"
if parallelrun == True:
data = PRDF
data1 = data
data2 = data1[0].upper() + data1[1:]
data3 = data2[:-3] + data2[-2].upper() + data2[-1].upper()
command2 = f"kotlinc {data1} & kotlin {data3}.class"
print(command2)
if CAROCO == 2:
command = "kotlinc runned_code.kt"
if parallelrun == True:
command2 = f"kotlinc {PRDF}"
if CAROCO != 1 and CAROCO != 2:
print('the value of CAROCO perimeter it is out of range or is not a integer value')
exit()
if programminglanguage != 'data':
with open(f"runned_code{programminglanguagefileformat}", "w") as file:
file.write(f'{code}')
if parallelrun == True:
with open(f"{PRDF}", "w") as file2:
file2.write('')
with open(f"{PRDF}", "w") as file:
file.write(f'{code}')
if CAROCO == 1:
os.system(f'start cmd /k {command2}')
else:
if CAROCO == 1:
subprocess.Popen(command, shell=True).wait()
y = int(time.strftime('%Y%d%d%H%M%S'))
end_time = time.time()
time_diff = end_time - start_time
if CAROCO == 1:
if parallelrun == True and showrunmessage == True:
os.system(f"echo the {PRDF} file running by using parallel run🔥")
if parallelrun == False and showrunmessage == True:
print('note:running more than normal run like the all run_pre or else make the compiler')
print('shows the run time is add to the run time before it')
print(f"{programminglanguage.upper()} Finished in {time_diff:.3f} seconds")
if showmessageshowingwarnings == True and parallelrun == True and showrunmessage == True:
print('if the terminal or any another way to show the run message and you run the code')
print('by using parallel run you could found |?|')
print('this is because your terminal cannot show emojis (flame emoji)')
else:
print(f'The compiling process is 100% completed for runned_code{programminglanguagefileformat}')
if returned == True:
fooe = open("run_system_functions_AOC.txt", 'w')
fooe.write(code)
SET_NO_STATEMENT_FUNCTION_CALLING = list_to_string(find_between2(options, '$<set no statement function calling>','/set no statement function calling>$', 1))
def run(programminglanguage:str,CAROCO:int, returned:bool, file_path:str='', thecode:str='', PRDF:str='', Parallelrun:bool=False, showrunmessage:bool=True, showmessageshowingwarnings:bool=False,datalogfilename:str=''):
func_mapping_var = {}
if CAROCO == 1:
runned = True
if CAROCO == 2:
runned = False
if CAROCO != 1 and CAROCO != 2:
print('the "CAROCO" parameter has an invalid value')
fl = open('run_system_functions_AOC.txt','w')
fl.write('')
fl.close()
if programminglanguage == 'python':
func_mapping_var = PAPFL.func_mapping.keys()
if programminglanguage == 'C' or programminglanguage == 'c':
func_mapping_var = CAPFL.func_mapping.keys()
if programminglanguage == 'java':
func_mapping_var = JAPFL.func_mapping.keys()
if programminglanguage == 'javascript' or programminglanguage == 'JS':
func_mapping_var = JSAPFL.func_mapping.keys()
if programminglanguage == 'batch':
func_mapping_var = BAPFL.func_mapping.keys()
if programminglanguage == 'kotlin':
func_mapping_var = KTAPFL.func_mapping.keys()
if programminglanguage == 'html':
func_mapping_var = HAPFL.func_mapping.keys()
if programminglanguage != 'python' and programminglanguage != 'C' and programminglanguage != 'c'and programminglanguage != 'java' and programminglanguage != 'javascript' and programminglanguage != 'JS' and programminglanguage != 'batch' and programminglanguage != 'kotlin' and programminglanguage != 'html' and programminglanguage != 'data':
print("unknown programming language")
exit()
if file_path != '':
if os.path.exists(file_path):
with open(file_path, 'r') as f:
code1 = f.read()
for i in range(100000):
if programminglanguage != 'all' and f'<{programminglanguage} s>{i + 1}' in code1:
code2 = list_to_string2(find_between2_2(code1,f'<{programminglanguage} s>{i + 1}', f'<{programminglanguage} e>{i + 1}', 1))
py = open('run_system_functions_AOC.txt', 'a')
print(code2, file=py)
py.close()
global start_time,command2,command,token_message,token_message2,token_message3,token_message4,programminglanguagefileformat,func_mapping_var2,options,SET_NO_STATEMENT_FUNCTION_CALLING
codeh = open('run_system_functions_AOC.txt', 'r')
helpercode = codeh.read()
codeh.close()
x = int(time.strftime('%Y%d%d%H%M%S'))
code = compile('c','',helpercode,programminglanguage)
runner(code, programminglanguage, CAROCO, PRDF, Parallelrun, showrunmessage, showmessageshowingwarnings,
returned, datalogfilename) # type: ignore
if returned == True:
return code
closersfa = open('run_system_functions_AOC.txt', 'w')
closersfa.write('')
closersfa.close()
else:
print(f"The file '{file_path}' does not exist")
else:
for i in range(100000):
if f'<{programminglanguage} s>{i + 1}' in thecode:
code1 = list_to_string2(find_between2(thecode, f'<{programminglanguage} s>{i + 1}',f'<{programminglanguage} e>{i + 1}', 1))
py = open('run_system_functions_AOC.txt', 'a')
print(code1, file=py)
py.close()
global start_time,command2,command,token_message,token_message2,token_message3,token_message4,programminglanguagefileformat,func_mapping_var2,options,SET_NO_STATEMENT_FUNCTION_CALLING
codeh = open('run_system_functions_AOC.txt', 'r')
helpercode = codeh.read()
codeh.close()
x = int(time.strftime('%Y%d%d%H%M%S'))
code = compile('c','',helpercode,programminglanguage)
runner(code, programminglanguage, CAROCO, PRDF, Parallelrun, showrunmessage, showmessageshowingwarnings,
returned, datalogfilename) # type: ignore
if returned == True:
return code
closersfa = open('run_system_functions_AOC.txt', 'w')
closersfa.write('')
closersfa.close()
def parallelrunfilesgen(filename:str,fileformat:str):
try:
f = open(f'{filename}_PRDF{fileformat}','x')
except:
print("this file already exists")
def GLCfilegenrator(file_name_without_file_format:str,Python_PRDF:bool=False,C_PRDF:bool=False,Java_PRDF:bool=False,JS_PRDF:bool=False,HTML_PRDF:bool=False,Batch_PRDF:bool=False,Kotlin_PRDF:bool=False):
try:
ma = open(f'{file_name_without_file_format}.gcf','x')
ma.close()
except:
pass
if Python_PRDF == True:
try:
p1 = open(f'{file_name_without_file_format}_PRDF.py')
except:
pass
if C_PRDF == True:
try:
c1 = open(f'{file_name_without_file_format}_PRDF.c')
except:
pass
if Java_PRDF == True:
try:
j1 = open(f'{file_name_without_file_format}_PRDF.java')
except:
pass
if JS_PRDF == True:
try:
js1 = open(f'{file_name_without_file_format}_PRDF.js')
except:
pass
if HTML_PRDF == True:
try:
h1 = open(f'{file_name_without_file_format}_PRDF.html')
except:
pass
if Batch_PRDF == True:
try:
b1 = open(f'{file_name_without_file_format}_PRDF.bat')
except:
pass
if Kotlin_PRDF == True:
try:
k1 = open(f'{file_name_without_file_format}_PRDF.kt')
except:
pass
def GLCfilegenrator2(file_name_without_file_format,Python_PRDF:bool=True,C_PRDF:bool=True,Java_PRDF:bool=True,JS_PRDF:bool=True,HTML_PRDF:bool=True,Batch_PRDF:bool=True,Kotlin_PRDF:bool=True):
try:
ma = open(f'{file_name_without_file_format}.gcf','x')
ma.close()
except:
pass
if Python_PRDF == True:
try:
p1 = open(f'{file_name_without_file_format}_PRDF.py')
except:
pass
if C_PRDF == True:
try:
c1 = open(f'{file_name_without_file_format}_PRDF.c')
except:
pass
if Java_PRDF == True:
try:
j1 = open(f'{file_name_without_file_format}_PRDF.java')
except:
pass
if JS_PRDF == True:
try:
js1 = open(f'{file_name_without_file_format}_PRDF.js')
except:
pass
if HTML_PRDF == True:
try:
h1 = open(f'{file_name_without_file_format}_PRDF.html')
except:
pass
if Batch_PRDF == True:
try:
b1 = open(f'{file_name_without_file_format}_PRDF.bat')
except:
pass
if Kotlin_PRDF == True:
try:
k1 = open(f'{file_name_without_file_format}_PRDF.kt')
except:
pass