Whole file

lark-parser/lark

The author described this change as Fix literal range escape assertion. It counts as a record because the checks below fail on the code as it stood at ed46efbd1 and pass on d5c9006f0, with nothing else changed between the two runs.

Fix saved2019-02-23
Sharing licenceMIT · LICENSE
Change size+1 1

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

Fix literal range escape assertion

The change

389389 assert start.type == end.type == 'STRING'
390390 start = start.value[1:-1]
391391 end = end.value[1:-1]
392- assert len(start) == len(end) == 1, (start, end, len(start), len(end))
392+ assert len(_fix_escaping(start)) == len(_fix_escaping(end)) == 1, (start, end, len(_fix_escaping(start)), len(_fix_escaping(end)))
393393 regexp = '[%s-%s]' % (start, end)
394394 return ST('pattern', [PatternRE(regexp)])
395395

The check that tells the two apart

failpass·tests/test_parser.py::TestCykStandard::test_hex_literal_range_escape
failpass·tests/test_parser.py::TestCykStandard::test_unicode_literal_range_escape
failpass·tests/test_parser.py::TestEarleyDynamic::test_hex_literal_range_escape
failpass·tests/test_parser.py::TestEarleyDynamic::test_unicode_literal_range_escape
failpass·tests/test_parser.py::TestEarleyDynamic_complete::test_hex_literal_range_escape
failpass·tests/test_parser.py::TestEarleyDynamic_complete::test_unicode_literal_range_escape
failpass·tests/test_parser.py::TestEarleyStandard::test_hex_literal_range_escape
failpass·tests/test_parser.py::TestEarleyStandard::test_unicode_literal_range_escape
failpass·tests/test_parser.py::TestLalrContextual::test_hex_literal_range_escape
failpass·tests/test_parser.py::TestLalrContextual::test_unicode_literal_range_escape
failpass·tests/test_parser.py::TestLalrStandard::test_hex_literal_range_escape
failpass·tests/test_parser.py::TestLalrStandard::test_unicode_literal_range_escape

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 ited46efbd10b5daf154378a67f0beffbb9849bf3d
Broken version dated2019-02-15
Modulelark.load_grammar
Units changedPrepareLiterals
Fingerprint28dc66634643bf02
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