mirror of
https://github.com/davidhalter/parso.git
synced 2025-12-08 13:45:01 +08:00
Fix all tests except diff tests. Mostly error recovery fixes
This commit is contained in:
@@ -93,7 +93,7 @@ class Parser(BaseParser):
|
|||||||
# not what we want, we want a module, so we add it here:
|
# not what we want, we want a module, so we add it here:
|
||||||
node = self.convert_node(
|
node = self.convert_node(
|
||||||
self._pgen_grammar,
|
self._pgen_grammar,
|
||||||
self._pgen_grammar.nonterminal2number['file_input'],
|
'file_input',
|
||||||
[node]
|
[node]
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -214,15 +214,13 @@ class Parser(BaseParser):
|
|||||||
|
|
||||||
tos = stack[-1]
|
tos = stack[-1]
|
||||||
if tos.nonterminal == 'suite':
|
if tos.nonterminal == 'suite':
|
||||||
dfa, state, node = stack[-1]
|
# Need at least one statement in the suite. This happend with the
|
||||||
states, first = dfa
|
# error recovery above.
|
||||||
arcs = states[state]
|
try:
|
||||||
intended_label = pgen_grammar.nonterminal2label['stmt']
|
tos.dfa = tos.dfa.arcs['stmt']
|
||||||
# Introduce a proper state transition. We're basically allowing
|
except KeyError:
|
||||||
# there to be no valid statements inside a suite.
|
# We're already in a final state.
|
||||||
if [x[0] for x in arcs] == [intended_label]:
|
pass
|
||||||
new_state = arcs[0][1]
|
|
||||||
stack[-1] = dfa, new_state, node
|
|
||||||
|
|
||||||
def _stack_removal(self, stack, start_index):
|
def _stack_removal(self, stack, start_index):
|
||||||
all_nodes = []
|
all_nodes = []
|
||||||
|
|||||||
Reference in New Issue
Block a user