mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-08 14:54:47 +08:00
Finally passing all diff parser tests.
This commit is contained in:
@@ -58,9 +58,9 @@ def suite_or_file_input_is_valid(grammar, stack):
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
for dfa, newstate, (symbol_number, nodes) in reversed(stack):
|
for dfa, newstate, (symbol_number, nodes) in reversed(stack):
|
||||||
if symbol_number == grammar.symbol2number['suite']:
|
if grammar.number2symbol[symbol_number] == 'suite':
|
||||||
# If we don't have nodes already, the suite is not valid.
|
# If only newline is in the suite, the suite is not valid, yet.
|
||||||
return bool(nodes)
|
return len(nodes) > 1
|
||||||
# Not reaching a suite means that we're dealing with file_input levels
|
# Not reaching a suite means that we're dealing with file_input levels
|
||||||
# where there's no need for a valid statement in it. It can also be empty.
|
# where there's no need for a valid statement in it. It can also be empty.
|
||||||
return True
|
return True
|
||||||
|
|||||||
@@ -200,7 +200,7 @@ def test_for_on_one_line(differ):
|
|||||||
""")
|
""")
|
||||||
# The second parser is for parsing the `def nested()` which is an `equal`
|
# The second parser is for parsing the `def nested()` which is an `equal`
|
||||||
# operation in the SequenceMatcher.
|
# operation in the SequenceMatcher.
|
||||||
differ.parse(src, parsers=2, copies=1)
|
differ.parse(src, parsers=1, copies=1)
|
||||||
|
|
||||||
|
|
||||||
def test_open_parentheses(differ):
|
def test_open_parentheses(differ):
|
||||||
@@ -208,7 +208,7 @@ def test_open_parentheses(differ):
|
|||||||
code = u('isinstance(\n\n' + func)
|
code = u('isinstance(\n\n' + func)
|
||||||
differ.initialize(code)
|
differ.initialize(code)
|
||||||
|
|
||||||
differ.parse('isinstance(\n' + func, copies=1, parsers=1)
|
differ.parse('isinstance(\n' + func, parsers=1, allow_error_leafs=True)
|
||||||
|
|
||||||
|
|
||||||
def test_backslash(differ):
|
def test_backslash(differ):
|
||||||
@@ -238,4 +238,4 @@ def test_backslash(differ):
|
|||||||
def second():
|
def second():
|
||||||
pass
|
pass
|
||||||
""")
|
""")
|
||||||
differ.parse(src, parsers=2)
|
differ.parse(src, parsers=1)
|
||||||
|
|||||||
Reference in New Issue
Block a user