The new tokenizer is more or less working now. Indents are calculated as they should

This commit is contained in:
Dave Halter
2014-11-27 16:03:58 +01:00
parent c0df7003a5
commit 97516eb26b
3 changed files with 47 additions and 6 deletions

View File

@@ -131,7 +131,7 @@ class Parser(object):
p = pgen2.parse.Parser(grammar, self.convert_node, self.convert_leaf,
self.error_recovery)
tokenizer = tokenizer or tokenize.source_tokens(source)
self.module = p.parse(self._tokenize(tokenizer))
self.module = p.parse(p.tokenize(self._tokenize(tokenizer)))
self.module.used_names = self.used_names
self.module.path = module_path
@@ -247,6 +247,18 @@ class Parser(object):
stack[start_index:] = []
def _tokenize(self, tokenizer):
"""
while first_pos[1] <= self._scope.start_pos[1] \
and (token_type == tokenize.NAME or tok_str in ('(', '['))\
and self._scope != self.module:
self._scope.end_pos = first_pos
self._scope = self._scope.parent
if isinstance(self._scope, pr.Module) \
and not isinstance(self._scope, pr.SubModule):
self._scope = self.module
"""
new_scope = False
for token in tokenizer:
typ = token.type
value = token.value