Skip to content

Commit 483cfdf

Browse files
committed
fix: LR(1) items lookahead set calculation
1 parent d0aca9e commit 483cfdf

File tree

3 files changed

+4
-3
lines changed

3 files changed

+4
-3
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ backward incompatible changes will start to apply when the projects goes 1.0
2121
### Fixed
2222
- Fix `to_str` failure when calculating the number of solutions in the context
2323
of optional match ([#147]). Thanks @LVrecar for the report and fix.
24+
- Fix lookahead calculation in closure
2425

2526
### Changed
2627
- Drop support for Python 3.6/3.7

parglare/closure.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def closure(state, itemset_type, first_sets=None):
3030
for prod in [p for p in state.grammar.productions
3131
if p.symbol == symbol]:
3232
new_item = LRItem(prod, 0,
33-
follow if itemset_type is LR_1 else None)
33+
set(follow) if itemset_type is LR_1 else None)
3434
if new_item not in state.items:
3535
# If the item doesn't exists yet add it and reprocess it.
3636
state.items.append(new_item)

parglare/tables/__init__.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -238,10 +238,10 @@ def create_table(grammar, itemset_type=LR_1, start_production=1,
238238
update = False
239239

240240
for state in states:
241-
242-
# First refresh current state's follows
241+
# First refresh state's follows
243242
closure(state, LR_1, first_sets)
244243

244+
for state in states:
245245
# Propagate follows to next states. GOTOs/ACTIONs keep
246246
# information about states created from this state
247247
inc_items = [i.get_pos_inc() for i in state.items]

0 commit comments

Comments
 (0)