BoldCalc/sver
BoldCalc/disfavour
f1from re import *f1from re import *
nn2 
23
3dh = globals()4dh = globals()
4d = {}5d = {}
nn6# ([^0-9A-Za-z_](\d)+[eE][+-]\d)   \d[eE][+-]?\d
5base_mistake = compile(7base_mistake = compile(
6    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)')
7name_for_sub = compile(r"(?<!\w)([a-zA-Z_]\w*)")9name_for_sub = compile(r"(?<!\w)([a-zA-Z_]\w*)")
8name_for_match = compile(r"([a-zA-Z_]\w*)\s*=\s*(.*)")10name_for_match = compile(r"([a-zA-Z_]\w*)\s*=\s*(.*)")
9splitting_match = compile(r"([a-zA-Z_]\w*)\s*=\s*(.*)")11splitting_match = compile(r"([a-zA-Z_]\w*)\s*=\s*(.*)")
1012
1113
12def analyze(f):14def analyze(f):
13    if match(r"#", f) is None:15    if match(r"#", f) is None:
1416
15        if base_mistake.search(f):17        if base_mistake.search(f):
16            print("Syntax error")18            print("Syntax error")
17            return19            return
1820
19        f = sub(r"/", r"//", f)21        f = sub(r"/", r"//", f)
nn22        # print(f)
20        f = name_for_sub.sub(r"_c_\1", f)23        f = name_for_sub.sub(r"_c_\1", f)
nn24        # print(f)
2125
22        if name_for_sub.fullmatch(f):26        if name_for_sub.fullmatch(f):
23            try:27            try:
24                print(eval(f, dh, d))28                print(eval(f, dh, d))
25            except NameError:29            except NameError:
26                print("Name error")30                print("Name error")
27                return31                return
28            else:32            else:
29                return33                return
3034
31        elif name_for_match.match(f):35        elif name_for_match.match(f):
32            s = splitting_match.match(f)36            s = splitting_match.match(f)
33            left = s.group(1)37            left = s.group(1)
34            right = s.group(2)38            right = s.group(2)
nn39            #print(left, right)
3540
36            try:41            try:
37                right = eval(right, dh, d)42                right = eval(right, dh, d)
tt43                # print(right)
38            except NameError:44            except NameError:
39                print("Name error")45                print("Name error")
40                return46                return
41            except SyntaxError:47            except SyntaxError:
42                print("Syntax error")48                print("Syntax error")
43            else:49            else:
44                try:50                try:
45                    exec(left + "=" + str(right), dh, d)51                    exec(left + "=" + str(right), dh, d)
46                except SyntaxError:52                except SyntaxError:
47                    print("Syntax error")53                    print("Syntax error")
48                    return54                    return
49                else:55                else:
50                    return56                    return
5157
52        else:58        else:
53            if search(r"=", f):59            if search(r"=", f):
54                print("Assignment error")60                print("Assignment error")
55                return61                return
56            try:62            try:
57                print(eval(f, dh, d))63                print(eval(f, dh, d))
58            except NameError:64            except NameError:
59                print("Name error")65                print("Name error")
60                return66                return
61            except SyntaxError:67            except SyntaxError:
62                print("Syntax error")68                print("Syntax error")
63                return69                return
64            except BaseException:70            except BaseException:
65                print("Runtime error")71                print("Runtime error")
66                return72                return
67            else:73            else:
68                return74                return
6975
7076
71a = input()77a = input()
72while a:78while a:
73    analyze(a)79    analyze(a)
74    a = input()80    a = input()
7581
Legends
Colors
 Added 
Changed
Deleted
Links
(f)irst change
(n)ext change
(t)op