diff --git a/parglare/closure.py b/parglare/closure.py index 1199930..18315c5 100644 --- a/parglare/closure.py +++ b/parglare/closure.py @@ -30,7 +30,7 @@ def closure(state, itemset_type, first_sets=None): for prod in [p for p in state.grammar.productions if p.symbol == symbol]: new_item = LRItem(prod, 0, - follow if itemset_type is LR_1 else None) + set(follow) if itemset_type is LR_1 else None) if new_item not in state.items: # If the item doesn't exists yet add it and reprocess it. state.items.append(new_item) diff --git a/parglare/tables/__init__.py b/parglare/tables/__init__.py index 2711883..f981b62 100644 --- a/parglare/tables/__init__.py +++ b/parglare/tables/__init__.py @@ -238,10 +238,10 @@ def create_table(grammar, itemset_type=LR_1, start_production=1, update = False for state in states: - - # First refresh current state's follows + # First refresh state's follows closure(state, LR_1, first_sets) + for state in states: # Propagate follows to next states. GOTOs/ACTIONs keep # information about states created from this state inc_items = [i.get_pos_inc() for i in state.items]