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.
Projectlark-parser/lark
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
| 9 | 9 | # Author: Erez Sh | |
| 10 | 10 | ||
| 11 | 11 | 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)) | |
| 17 | 13 | ||
| 18 | 14 | def _sum_priority(tree): | |
| 19 | 15 | p = 0 |
The check that tells the two apart
fail→pass·tests/test_parser.py::TestFullEarleyDynamic::test_term_ambig_resolve
fail→pass·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
- 2026-07-08Fix lexer_callbacks silently dropped for keyword terminals
- 2026-06-24Transformer_NonRecursive
- 2026-06-04Raise GrammarError for non-terminal names in %declare
- 2026-06-02Fix empty SPPF node from xearley ignore carry-over (fixes #1598)
- 2026-05-24fix: raise GrammarError for template usage inside terminals
- 2024-10-25Adjust behaviour in #1481 to raise a NotImplementedError