private function validateDeterministicShiftReduce(
        array $finite,
        array $terminals,
        array $nonTerminals,
        Grammar $grammar
    ): void {
        if ($finite && $terminals) {
            $left_terminals = $grammar->getTerminals();
            foreach ($terminals as $item) {
                unset($left_terminals[$item->getExpected()->getName()]);
            }
            if (!$left_terminals) {
                throw new ConflictShiftReduceException(
                    array_merge($finite, $terminals, $nonTerminals)
                );
            }
        }
    }
private function validateDeterministicShiftReduce(
        array $finite,
        array $terminals,
        array $nonTerminals,
        Grammar $grammar
    ): void {
        if ($finite && $terminals) {
            $left_terminals = $grammar->getTerminals();
            foreach ($terminals as $item) {
                unset($left_terminals[$item->getExpected()->getName()]);
            }
            if (!$left_terminals) {
                throw new ConflictShiftReduceException(
                    array_merge($finite, $terminals, $nonTerminals)
                );
            }
        }
    }
private function validateDeterministicShiftReduce ( array $ finite , array $ terminals , array $ nonTerminals , Grammar $ grammar ) : void { if ( $ finite && $ terminals ) { $ left_terminals = $ grammar -> getTerminals ( ) ; foreach ( $ terminals as $ item ) { unset ( $ left_terminals [ $ item -> getExpected ( ) -> getName ( ) ] ) ; } if ( ! $ left_terminals ) { throw new ConflictShiftReduceException ( array_merge ( $ finite , $ terminals , $ nonTerminals ) ) ; } } }
Check for Shift-Reduce conflicts
@param Item[] $finite Items where all symbols are already passed
@param Item[] $terminals Items where next expected symbol is terminal
@param Item[] $nonTerminals Items where next expected symbol is non-terminal
@param Grammar $grammar Source grammar
@throws ConflictShiftReduceException Shift-reduce conflict is detected
Check for Shift - Reduce conflicts