-
Notifications
You must be signed in to change notification settings - Fork 1
/
parseNanoCode.py
32 lines (29 loc) · 1006 Bytes
/
parseNanoCode.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
f = open("input.txt", "r")
for line in f :
#print(line[:-1])
## remove comments
index=''
if '//[' in line :
index = line.split('//[')[1]
if '[' in index :
index = index.replace('[','')
if ']' in index :
index = index.replace(']','')
if ' ' in index:
index = index.replace(' ','')
if '\n' in index:
index = index.replace('\n','')
#print('index: ',index)
line = line.split('//')[0]
line = line.split(';')[0]
while " " in line :
line = line.replace(" "," ",1)
if line[0] == ' ':
line = line[1:]
words = line.split(' ')
words[1] = words[1].split('[')[0]
#print(words)
if index == '':
print("branch_map_"+words[0]+".insert( std::pair<string,"+words[0]+"*>( \""+words[1]+"\" , &"+words[1]+" ) ) ;")
else :
print("branch_map_"+words[0]+".insert( std::pair<string,"+words[0]+"*>( \""+words[1]+"\" , "+words[1]+" ) ) ; //"+index)