mirror of
https://github.com/davidhalter/jedi.git
synced 2026-02-12 07:51:41 +08:00
Now ErrorLeaf and ErrorNode are part of the syntax tree. This makes probably sense. The documentation will follow once it's clear how they will shape out.
This commit is contained in:
@@ -422,6 +422,8 @@ class ParserWithRecovery(Parser):
|
||||
# TODO document the shizzle!
|
||||
#self._error_statements.append(ErrorStatement(stack, None, None,
|
||||
# self.position_modifier, error_leaf.end_pos))
|
||||
error_leaf = pt.ErrorLeaf(self.position_modifier, value, start_pos, prefix)
|
||||
stack[-1][2][1].append(error_leaf)
|
||||
return
|
||||
|
||||
if typ == INDENT:
|
||||
@@ -462,17 +464,20 @@ class ParserWithRecovery(Parser):
|
||||
|
||||
failed_stack = []
|
||||
found = False
|
||||
all_nodes = []
|
||||
for dfa, state, (typ, nodes) in stack[start_index:]:
|
||||
if nodes:
|
||||
found = True
|
||||
if found:
|
||||
symbol = grammar.number2symbol[typ]
|
||||
failed_stack.append((symbol, nodes))
|
||||
all_nodes += nodes
|
||||
if nodes and nodes[0] in ('def', 'class', 'lambda'):
|
||||
self._scope_names_stack.pop()
|
||||
if failed_stack:
|
||||
err = ErrorStatement(failed_stack, arcs, value, self.position_modifier, start_pos)
|
||||
self._error_statements.append(err)
|
||||
stack[start_index - 1][2][1].append(pt.ErrorNode(all_nodes))
|
||||
|
||||
self._last_failed_start_pos = start_pos
|
||||
|
||||
|
||||
@@ -641,6 +641,22 @@ class Node(BaseNode):
|
||||
return "%s(%s, %r)" % (self.__class__.__name__, self.type, self.children)
|
||||
|
||||
|
||||
class ErrorNode(BaseNode):
|
||||
"""
|
||||
TODO doc
|
||||
"""
|
||||
__slots__ = ()
|
||||
type = 'error_node'
|
||||
|
||||
|
||||
class ErrorLeaf(Leaf):
|
||||
"""
|
||||
TODO doc
|
||||
"""
|
||||
__slots__ = ()
|
||||
type = 'error_leaf'
|
||||
|
||||
|
||||
class IsScopeMeta(type):
|
||||
def __instancecheck__(self, other):
|
||||
return other.is_scope()
|
||||
|
||||
Reference in New Issue
Block a user