BoldCalc/disfavour
BoldCalc/warnachinka
t1from re import *t1from re import *
22
33
4dh = globals()4dh = globals()
5d = {}5d = {}
6# ([^0-9A-Za-z_](\d)+[eE][+-]\d)   \d[eE][+-]?\d6# ([^0-9A-Za-z_](\d)+[eE][+-]\d)   \d[eE][+-]?\d
7base_mistake = compile(7base_mistake = compile(
8    r'/{2,}|\*\*|[a-zA-Z0-9]\w*\(|\.|([^0-9A-Za-z_](\d)+[eE][+-]\d)')8    r'/{2,}|\*\*|[a-zA-Z0-9]\w*\(|\.|([^0-9A-Za-z_](\d)+[eE][+-]\d)')
9name_for_sub = compile(r"(?<!\w)([a-zA-Z_]\w*)")9name_for_sub = compile(r"(?<!\w)([a-zA-Z_]\w*)")
10name_for_match = compile(r"([a-zA-Z_]\w*)\s*=\s*(.*)")10name_for_match = compile(r"([a-zA-Z_]\w*)\s*=\s*(.*)")
11splitting_match = compile(r"([a-zA-Z_]\w*)\s*=\s*(.*)")11splitting_match = compile(r"([a-zA-Z_]\w*)\s*=\s*(.*)")
1212
1313
14def analyze(f):14def analyze(f):
15    if match(r"#", f) is None:15    if match(r"#", f) is None:
1616
17        if base_mistake.search(f):17        if base_mistake.search(f):
18            print("Syntax error")18            print("Syntax error")
19            return19            return
2020
21        f = sub(r"/", r"//", f)21        f = sub(r"/", r"//", f)
22        # print(f)22        # print(f)
23        f = name_for_sub.sub(r"_c_\1", f)23        f = name_for_sub.sub(r"_c_\1", f)
24        # print(f)24        # print(f)
2525
26        if name_for_sub.fullmatch(f):26        if name_for_sub.fullmatch(f):
27            try:27            try:
28                print(eval(f, dh, d))28                print(eval(f, dh, d))
29            except NameError:29            except NameError:
30                print("Name error")30                print("Name error")
31                return31                return
32            else:32            else:
33                return33                return
3434
35        elif name_for_match.match(f):35        elif name_for_match.match(f):
36            s = splitting_match.match(f)36            s = splitting_match.match(f)
37            left = s.group(1)37            left = s.group(1)
38            right = s.group(2)38            right = s.group(2)
39            #print(left, right)39            #print(left, right)
4040
41            try:41            try:
42                right = eval(right, dh, d)42                right = eval(right, dh, d)
43                # print(right)43                # print(right)
44            except NameError:44            except NameError:
45                print("Name error")45                print("Name error")
46                return46                return
47            except SyntaxError:47            except SyntaxError:
48                print("Syntax error")48                print("Syntax error")
49            else:49            else:
50                try:50                try:
51                    exec(left + "=" + str(right), dh, d)51                    exec(left + "=" + str(right), dh, d)
52                except SyntaxError:52                except SyntaxError:
53                    print("Syntax error")53                    print("Syntax error")
54                    return54                    return
55                else:55                else:
56                    return56                    return
5757
58        else:58        else:
59            if search(r"=", f):59            if search(r"=", f):
60                print("Assignment error")60                print("Assignment error")
61                return61                return
62            try:62            try:
63                print(eval(f, dh, d))63                print(eval(f, dh, d))
64            except NameError:64            except NameError:
65                print("Name error")65                print("Name error")
66                return66                return
67            except SyntaxError:67            except SyntaxError:
68                print("Syntax error")68                print("Syntax error")
69                return69                return
70            except BaseException:70            except BaseException:
71                print("Runtime error")71                print("Runtime error")
72                return72                return
73            else:73            else:
74                return74                return
7575
7676
77a = input()77a = input()
78while a:78while a:
79    analyze(a)79    analyze(a)
80    a = input()80    a = input()
8181
Legends
Colors
 Added 
Changed
Deleted
Links
(f)irst change
(n)ext change
(t)op