straightline/src/main/java/org/poormanscastle/studies/compilers/utils/grammartools/lr/LR0Grammar.java
/**
     * calculates the closure for a state, i.e. add more items to the state when there is a dot to the left
     * of a nonterminal.
     *
     * @param state
     * @return state for method call chaining there reference to the given state is returned.
     */
calculates the closure for a state, i.e. add more items to the state when there is a dot to the left
of a nonterminal.

@param state
@return state for method call chaining there reference to the given state is returned.
calculates the closure for a state i . e . add more items to the state when there is a dot to the left of a nonterminal . @param state @return state for method call chaining there reference to the given state is returned .
public LRState calculateClosure(LRState state) {
        int oldSize;
        do {
            List<LRItem> deltaList = new LinkedList<>();
            oldSize = state.getItems().size();
            for (LRItem item : state.getItems()) {
                if (!item.isReducible() && !item.getNextSymbol().isTerminal()) {
                    for (Production production : productions) {
                        if (item.getNextSymbol() == production.getLhs()) {
                            deltaList.add(new LRItem(production));
                        }
                    }
                }
            }
            state.getItems().addAll(deltaList);
            checkState(oldSize <= state.getItems().size());
        } while (oldSize < state.getItems().size());
        return state;
    }
public LRState calculateClosure ( LRState state ) { int oldSize ; do { List < LRItem > deltaList = new LinkedList < > ( ) ; oldSize = state . getItems ( ) . size ( ) ; for ( LRItem item : state . getItems ( ) ) { if ( ! item . isReducible ( ) && ! item . getNextSymbol ( ) . isTerminal ( ) ) { for ( Production production : productions ) { if ( item . getNextSymbol ( ) == production . getLhs ( ) ) { deltaList . add ( new LRItem ( production ) ) ; } } } } state . getItems ( ) . addAll ( deltaList ) ; checkState ( oldSize <= state . getItems ( ) . size ( ) ) ; } while ( oldSize < state . getItems ( ) . size ( ) ) ; return state ; }
calculates the closure for a state, i.e.
calculates the closure for a state i . e .