Whole file

lark-parser/lark

The author described this change as BUGFIX: Solved an elusive bug in Earley parser, when empty rules repeat in the same column. It counts as a record because the check below fails on the code as it stood at a7f99dd8c and passes on 1685f94ea, with nothing else changed between the two runs.

Fix saved2017-04-05
Sharing licenceMIT · LICENSE
Change size+2 2

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

BUGFIX: Solved an elusive bug in Earley parser, when empty rules repeat in the same column

The change

9898 for item in items:
9999
100100 if item.is_complete:
101- # XXX TODO Potential bug: What happens if there's ambiguity in an empty rule?
101+ # XXX Potential bug: What happens if there's ambiguity in an empty rule?
102102 if item.rule.expansion and item in self.completed:
103103 old_tree = self.completed[item].tree
104104 if old_tree.data != 'ambig':
110110 old_tree.children.append(item.tree)
111111 else:
112112 self.completed[item] = item
113- self.to_reduce.append(item)
113+ self.to_reduce.append(item)
114114 else:
115115 if item not in added:
116116 added.add(item)

The check that tells the two apart

failpass·tests/test_parser.py::TestEarley::test_earley_repeating_empty

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 ita7f99dd8c6a8472fb4e05c4634b248887d0e39e9
Broken version dated2017-03-20
Modulelark.parsers.earley
Units changedColumn
Fingerprinta706e686fcb5564d
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