Whole file

lark-parser/lark

The author described this change as Fixed bug in Earley prioritization. It counts as a record because the checks below fail on the code as it stood at 25c3c51b1 and pass on 4f2330fc9, with nothing else changed between the two runs.

Fix saved2018-04-05
Sharing licenceMIT · LICENSE
Change size+1 5

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

Fixed bug in Earley prioritization

The change

99 # Author: Erez Sh
1010
1111 def _compare_rules(rule1, rule2):
12- c = -compare( len(rule1.expansion), len(rule2.expansion))
13- if rule1.origin.startswith('__'): # XXX hack! We should set priority in parser, not here
14- c = -c
15- return c
16-
12+ return -compare( len(rule1.expansion), len(rule2.expansion))
1713
1814 def _sum_priority(tree):
1915 p = 0

The check that tells the two apart

failpass·tests/test_parser.py::TestFullEarleyDynamic::test_term_ambig_resolve
failpass·tests/test_parser.py::TestFullEarleyScanless::test_term_ambig_resolve

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 it25c3c51b1c6c096b6e4bcfe63d543fece572b72d
Broken version dated2018-04-05
Modulelark.parsers.resolve_ambig
Units changed_compare_rules
Fingerprintcf7d1650b700e7e6
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