1
0
forked from VimPlug/jedi

more change to simplify the statement parser

This commit is contained in:
Dave Halter
2014-02-27 16:58:08 +01:00
parent 8688def619
commit 1eba63760e
3 changed files with 14 additions and 11 deletions

View File

@@ -1100,7 +1100,13 @@ isinstance(c, (tokenize.Token, Operator)) else unicode(c)
token_iterator = common.PushBackIterator(enumerate(self.token_list))
for i, tok in token_iterator:
if isinstance(tok, Base):
if isinstance(tok, tokenize.Token):
token_type = tok.type
tok_str = tok.string
if tok_str == 'as': # just ignore as, because it sets values
next(token_iterator, None)
continue
else:
# the token is a Name, which has already been parsed
tok_str = tok
token_type = None
@@ -1112,12 +1118,6 @@ isinstance(c, (tokenize.Token, Operator)) else unicode(c)
result = []
is_chain = False
continue
else:
token_type = tok.type
tok_str = tok.string
if tok_str == 'as': # just ignore as, because it sets values
next(token_iterator, None)
continue
if tok_str == 'lambda':
lambd, tok_str = parse_lambda(token_iterator)
@@ -1180,8 +1180,9 @@ isinstance(c, (tokenize.Token, Operator)) else unicode(c)
result = []
is_chain = False
else:
if token_type != tokenize.COMMENT:
result.append(tok_str)
# comments, strange tokens (like */**), error tokens to
# reproduce the string correctly.
result.append(tok)
return result