-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcompile.py
More file actions
31 lines (29 loc) · 878 Bytes
/
compile.py
File metadata and controls
31 lines (29 loc) · 878 Bytes
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
#python compile.py "iyu源文件" "输出文件.java"
import sys
import tokenizer
import tojava
def main():
iyu_file_name = sys.argv[1]
out_file_name = sys.argv[2]
out_file = open(out_file_name,"w",encoding="utf-8")
for line in open(iyu_file_name,"r",encoding="utf-8"):
#print(line,end="")
#判断注释
meet_zhushi = False
chars = ""
for char in line:
chars += char
if chars == "//":
print("遇到注释,跳过此行!")
meet_zhushi = True
break
if meet_zhushi:
continue
else:
syntax_data = tokenizer.split_head(line)
out_line = tojava.head_to_java(syntax_data)
print("编译 >>> "+str(out_line))
out_file.write(str(out_line)+"\n")
out_file.close()
pass
main()