-
Notifications
You must be signed in to change notification settings - Fork 0
/
convertRange.py
executable file
·42 lines (34 loc) · 1.13 KB
/
convertRange.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
import tokenize
from getFunctionExpression import getFunctionExpression
__author__ = 'Alexis Shaw'
def convertRange(token, line, t,v,i,understood, variables):
iOrig = i
i += 1
if v!= 'range':
print 'error'
return
t,v,_,_,_ = token[i]
number1 = ''
number2 = ''
number3 = ''
maxCount = 0
if t == tokenize.OP and v == '(':
maxCount = 1
i += 1
number1, i, understood,variables = getFunctionExpression(token, number1,t,v,i,understood,variables, '')
if token[i-1][1] == ',':
maxCount = 2
number2, i, understood,variables = getFunctionExpression(token, number2,t,v,i,understood,variables, '')
if token[i-1][1] == ',':
maxCount = 3
number3, i, understood,variables = getFunctionExpression(token, number3,t,v,i,understood,variables, '')
if maxCount == 1:
line += '(0 .. '+ number1 + '+ 1 ) '
i -= 1
elif maxCount == 2:
line += '(' + number1 + '.. ' + number2 + '- 1 )'
i -= 1
else:
understood = False
i = iOrig
return line,i,understood,variables