-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathshython.py
More file actions
75 lines (50 loc) · 1.84 KB
/
shython.py
File metadata and controls
75 lines (50 loc) · 1.84 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
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
from Tkinter import *
from Compiler.codegenerator import CodeGenerator
from Initializer.initialiser import Initializer
from Compiler.tokenizer import Tokenizer
from Compiler.semantic_analyser import SemanticAnalyser
from Initializer.screen import Screen
def check_semantic_analysis():
print "Tokenised list ----> ", tokenised_list
semantic_analyser = SemanticAnalyser(tokenised_list)
err = semantic_analyser.check_for_errors(available_class_list,
available_func_with_classes)
if err == "semantic":
return "semantic"
elif err == "syntax":
return "syntax"
else:
return "no_error"
def use_screen():
s = Screen()
width, height = s.get_screen_dimen()
s.make(master=master)
if __name__ == '__main__':
master = Tk()
file_name = sys.argv[1]
initializer = Initializer()
available_class_list = initializer.initialize_class_list()
print "Available class list : ", available_class_list
available_func_with_classes = initializer.initialize_dict_func()
print "Avaialable func with classes : ", available_func_with_classes
tokenised_list = Tokenizer().tokenise(file_name)
# print tokenised_list
err_msg = check_semantic_analysis()
if err_msg == "no_error":
print "No Syntax Error"
print "No Semantic Error"
codegenerator = CodeGenerator()
if codegenerator.check_screen(tokenised_list):
print "Screen initialised"
use_screen()
# print "*****"
codegenerator.check_for_shapes()
print "Code Generated"
mainloop()
else:
print "Screen not initialized"
else:
if err_msg == "semantic":
print "Semantic Error Raised"
elif err_msg == "syntax":
print "Syntax Error Raised"