1
0
forked from VimPlug/jedi

Splitting up the convert function into leaves and nodes.

This commit is contained in:
Dave Halter
2014-11-04 18:54:25 +01:00
parent d483d50284
commit f3e4bf9ed1
4 changed files with 45 additions and 37 deletions

View File

@@ -117,16 +117,4 @@ def convert(grammar, raw_node):
except KeyError:
return pr.Node(type, children)
else:
#print('leaf', raw_node, type_repr(type))
prefix, start_pos = context
if type == tokenize.NAME:
if value in grammar.keywords:
return pr.Keyword(value, start_pos, prefix)
else:
return pr.Name(value, start_pos, prefix)
elif type in (tokenize.STRING, tokenize.NUMBER):
return pr.Literal(value, start_pos, prefix)
elif type in (tokenize.NEWLINE, tokenize.ENDMARKER):
return pr.Whitespace(value, start_pos, prefix)
else:
return pr.Operator(value, start_pos, prefix)
raise NotImplementedError