-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.py
68 lines (56 loc) · 1.1 KB
/
main.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
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
import os
import eval
import usage
import InfixTopostfix
import postfix
import re
import table
def Main(out, read,Reg_no):
f = open("symbol_temp.txt", "w")
f.close()
f = open("symbol_original.txt", "w")
f.close()
tostr = []
#f = open('input.txt', 'r')
#read = f.readlines()
k = 0
for input_exp in read:
#print '\n\n'+input_exp
input_exp = str(input_exp)
#print k
k = eval.eval(input_exp, k, tostr)
#input_exp = raw_input('Enter the Expression : ')
#eval.eval(input_exp)
f.close()
d = []
f1 = open('inout.txt' , 'r')
lines = f1.readlines()
f1.close()
os.system('rm inout.txt')
for i in lines:
i = i.split('\n')
d.append(i[0])
quad = []
j = 0
for i in d:
quad.append(re.findall('\w+|\+|-|\*', d[j]))
j = j + 1
t = usage.gen(quad)
#print t
f = 0
#print t
# print '\n\n\n'
# for i , j in t.iteritems():
# for k in j:
# print k[0],'\t',
# print 'lu'+str(k[1]),'\t',
# if k[2] == None:
# print 'nnu\t',
# else:
# print 'nu'+str(k[2])+'\t',
# print
# print
# print
# print quad
table.get(quad , t,out, Reg_no, tostr)
os.system("rm symbol_temp.txt")