Whole file

lark-parser/lark

The author described this change as Fix #696 now providing the correct amount of placeholders. It counts as a record because the checks below fail on the code as it stood at 44a20c850 and pass on c3fc2266e, with nothing else changed between the two runs.

Fix saved2021-06-26
Sharing licenceMIT · LICENSE
Change size+4 5

What the code was meant to do, written into the code itself as a save note

Fix #696 now providing the correct amount of placeholders

The change

231231 return not sym.name.startswith('_')
232232 if isinstance(sym, Terminal):
233233 return keep_all_tokens or not sym.filter_out
234- assert False
234+ if isinstance(sym, Symbol):
235+ return False
236+ assert False, sym
235237
236- if any(rule.scan_values(will_not_get_removed)):
237- empty = _EMPTY
238- else:
239- empty = ST('expansion', [])
238+ empty = ST('expansion', [_EMPTY] * len(list(rule.scan_values(will_not_get_removed))))
240239
241240 return ST('expansions', [rule, empty])
242241

The check that tells the two apart

failpass·tests/test_parser.py::TestEarleyCustom_old::test_maybe_placeholders
failpass·tests/test_parser.py::TestEarleyDynamic::test_maybe_placeholders
failpass·tests/test_parser.py::TestEarleyDynamic_complete::test_maybe_placeholders
failpass·tests/test_parser.py::TestEarleyStandard::test_maybe_placeholders
failpass·tests/test_parser.py::TestLalrContextual::test_maybe_placeholders
failpass·tests/test_parser.py::TestLalrCustom_new::test_maybe_placeholders
failpass·tests/test_parser.py::TestLalrStandard::test_maybe_placeholders

Check file tests/test_parser.py, taken without changes from the fix and copied onto the older code, so the exact same check runs against both versions.

Origin and history

The code before it44a20c850ea7e0945a9db663a763abdcf1f86b88
Broken version dated2021-06-26
Modulelark.load_grammar
Units changedEBNF_to_BNF
Fingerprint8fac87f1c3bd7f56
Checked2026-08-18 by goldset/0.1

Every field above is generated by our program. None of it is written by hand.

Other bugs found in lark-parser/lark