-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconvertListLiteral.py
executable file
·28 lines (26 loc) · 1.27 KB
/
convertListLiteral.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
import re
import tokenize
import convertToken
__author__ = 'Alexis Shaw'
def convertListLiteral(token,line,t,v,i,understood,variables):
line += '( '
i += 1
while len(token)-i > 0 :
(t, v, _, _,_) = token[i]
if t == tokenize.NAME:
line,i,understood,variables = convertToken.convertToken(token, line,t,v,i,understood,variables,'')
elif t == tokenize.OP and re.match(r'^[([<>&^|~=+,*%-]$|^\*\*$|<<|>>|>=|<=|!=|==',v):
line,i,understood,variables = convertToken.convertToken(token, line,t,v,i,understood,variables,'')
elif t == tokenize.NL or t == tokenize.NUMBER:
line,i,understood,variables = convertToken.convertToken(token,line,t,v,i,understood,variables,'')
elif t == tokenize.STRING:
line,i,understood,variables = convertToken.convertToken(token,line,t,v,i,understood,variables,'')
elif t == tokenize.COMMENT and token[i+1][0] == tokenize.NL:
line,i,understood,variables = convertToken.convertToken(token,line,t,v,i,understood,variables,'')
elif t == tokenize.OP and re.match('[\]]', v):
line += ')' + ' '
break
else: understood = False
i += 1
#line += tokenize.tok_name[t]
return line, i, understood, variables