-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtestPost.py
More file actions
26 lines (21 loc) · 796 Bytes
/
testPost.py
File metadata and controls
26 lines (21 loc) · 796 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
# testing postFixer and postFixEval
#( 6 + 2 ) * 5 - 8 / 4 ==>> 6 2 + 5 * 8 4 / - ==>> 38
# to test, uncomment lines 8, 11-13, 23, 24
# be aware, convert silent operates on lists, verbose converts a string
# so evaluate the appropriate conversion
import postFixer
import postFixEval
#from sys import argv
verbose = False
#if argv.__len__() > 1 :
# if argv[ 1 ] == '-v' :
# verbose = True
yes = '0'
while yes == '0' :
test = raw_input( " expression to fix -- " )
print test # .rstrip( '\n' )
stepOne = postFixer.convertToPostFix( test, verbose ) # verbose mode
yes = raw_input( "\tagain? (1/0) -- " )
# stepOne = [ '6', '2', '+', '5', '*', '8', '4', '/', '-' ] # expression from header
# stepOne = [ '12', '10', '-', '4', '+', '2', '-' ]
# print postFixEval.evaluatePostfix( stepOne )