1
0
forked from VimPlug/jedi

Add the parsers flow information as classes to parser.representation.

This commit is contained in:
Dave Halter
2014-11-03 18:25:10 +01:00
parent e25684d470
commit 55db65434c
2 changed files with 32 additions and 2 deletions

View File

@@ -84,6 +84,11 @@ def convert(grammar, raw_node):
'global_stmt': pr.GlobalStmt,
'nonlocal_stmt': pr.KeywordStatement,
'assert_stmt': pr.KeywordStatement,
'if_stmt': pr.IfStmt,
'with_stmt': pr.WithStmt,
'for_stmt': pr.ForStmt,
'while_stmt': pr.WhileStmt,
'try_stmt': pr.TryStmt,
}
ast_mapping = dict((getattr(python_symbols, k), v) for k, v in _ast_mapping.items())

View File

@@ -470,7 +470,8 @@ class Scope(Simple, DocstringMixin):
for element in children:
if isinstance(element, typ):
elements.append(element)
elif is_node(element, 'suite') or is_node(element, 'simple_stmt'):
elif is_node(element, 'suite') or is_node(element, 'simple_stmt') \
or isinstance(element, Flow):
elements += scan(element.children)
return elements
@@ -859,7 +860,31 @@ class Lambda(Function):
self.start_pos[1], self.end_pos[1])
class Flow(Scope):
class Flow(Simple):
pass
class IfStmt(Flow):
pass
class WhileStmt(Flow):
pass
class ForStmt(Flow):
pass
class TryStmt(Flow):
pass
class WithStmt(Flow):
pass
class Flow_old(Scope):
"""
Used to describe programming structure - flow statements,
which indent code, but are not classes or functions: