forked from VimPlug/jedi
Remove the strange check in the parser to always create expr_stmt and file_input.
This commit is contained in:
@@ -153,6 +153,12 @@ class Parser(object):
|
|||||||
self.error_recovery)
|
self.error_recovery)
|
||||||
tokenizer = tokenizer or tokenize.source_tokens(source)
|
tokenizer = tokenizer or tokenize.source_tokens(source)
|
||||||
self.module = p.parse(self._tokenize(tokenizer))
|
self.module = p.parse(self._tokenize(tokenizer))
|
||||||
|
if self.module.type != 'file_input':
|
||||||
|
# If there's only one statement, we get back a non-module. That's
|
||||||
|
# not what we want, we want a module, so we add it here:
|
||||||
|
self.module = self.convert_node(grammar,
|
||||||
|
grammar.symbol2number['file_input'],
|
||||||
|
[self.module])
|
||||||
|
|
||||||
if added_newline:
|
if added_newline:
|
||||||
self.remove_last_newline()
|
self.remove_last_newline()
|
||||||
|
|||||||
@@ -190,11 +190,10 @@ class PgenParser(object):
|
|||||||
# If there's exactly one child, return that child instead of creating a
|
# If there's exactly one child, return that child instead of creating a
|
||||||
# new node. We still create expr_stmt and file_input though, because a
|
# new node. We still create expr_stmt and file_input though, because a
|
||||||
# lot of Jedi depends on its logic.
|
# lot of Jedi depends on its logic.
|
||||||
if len(children) != 1 or type in (-1,
|
if len(children) == 1:
|
||||||
self.grammar.symbol2number['file_input']):
|
|
||||||
newnode = self.convert_node(self.grammar, type, children)
|
|
||||||
else:
|
|
||||||
newnode = children[0]
|
newnode = children[0]
|
||||||
|
else:
|
||||||
|
newnode = self.convert_node(self.grammar, type, children)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# Equal to:
|
# Equal to:
|
||||||
|
|||||||
Reference in New Issue
Block a user