forked from VimPlug/jedi
Starting with Python 3.4 from is not a token that always is a "new" statement.
This commit is contained in:
@@ -165,7 +165,8 @@ class Parser(object):
|
||||
typ = token.opmap[value]
|
||||
yield typ, value, prefix, start_pos
|
||||
|
||||
def error_recovery(self, *args, **kwargs):
|
||||
def error_recovery(self, grammar, stack, typ, value, start_pos, prefix,
|
||||
add_token_callback):
|
||||
raise ParseError
|
||||
|
||||
def convert_node(self, grammar, type, children):
|
||||
@@ -207,7 +208,7 @@ class Parser(object):
|
||||
return new_node
|
||||
|
||||
def convert_leaf(self, grammar, type, value, prefix, start_pos):
|
||||
#print('leaf', value, pytree.type_repr(type))
|
||||
#print('leaf', repr(value), token.tok_ntype)
|
||||
if type == tokenize.NAME:
|
||||
if value in grammar.keywords:
|
||||
if value in ('def', 'class', 'lambda'):
|
||||
@@ -350,7 +351,7 @@ class ParserWithRecovery(Parser):
|
||||
# Otherwise the parser will get into trouble and DEDENT too early.
|
||||
self._omit_dedent_list.append(self._indent_counter)
|
||||
|
||||
if value in ('import', 'from', 'class', 'def', 'try', 'while', 'return'):
|
||||
if value in ('import', 'class', 'def', 'try', 'while', 'return'):
|
||||
# Those can always be new statements.
|
||||
add_token_callback(typ, value, prefix, start_pos)
|
||||
elif typ == DEDENT and symbol == 'suite':
|
||||
|
||||
@@ -143,7 +143,7 @@ del _compile
|
||||
|
||||
tabsize = 8
|
||||
|
||||
ALWAYS_BREAK_TOKENS = (';', 'import', 'from', 'class', 'def', 'try', 'except',
|
||||
ALWAYS_BREAK_TOKENS = (';', 'import', 'class', 'def', 'try', 'except',
|
||||
'finally', 'while', 'return')
|
||||
|
||||
|
||||
|
||||
@@ -1319,6 +1319,8 @@ class ReturnStmt(KeywordStatement):
|
||||
|
||||
class YieldExpr(BaseNode):
|
||||
__slots__ = ()
|
||||
def __init__(self, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
def type(self):
|
||||
return 'yield_expr'
|
||||
|
||||
Reference in New Issue
Block a user