src/Tokens/Tokenizer.php
private function readAlternativeSentenceOrSingle($input, &$i)
    {
        $tokens = array();

        while (true) {
            $tokens []= $this->readSentenceOrSingle($input, $i);

            // end of input reached or end token found
            if (!isset($input[$i]) || strpos('])', $input[$i]) !== false) {
                break;
            }

            // cursor now at alternative symbol (all other symbols are already handled)
            // skip alternative mark and continue with next alternative
            $i++;
        }

        // return a single token as-is
        if (isset($tokens[0]) && !isset($tokens[1])) {
            return $tokens[0];
        }

        return new AlternativeToken($tokens);
    }
private function readAlternativeSentenceOrSingle($input, &$i)
    {
        $tokens = array();

        while (true) {
            $tokens []= $this->readSentenceOrSingle($input, $i);

            // end of input reached or end token found
            if (!isset($input[$i]) || strpos('])', $input[$i]) !== false) {
                break;
            }

            // cursor now at alternative symbol (all other symbols are already handled)
            // skip alternative mark and continue with next alternative
            $i++;
        }

        // return a single token as-is
        if (isset($tokens[0]) && !isset($tokens[1])) {
            return $tokens[0];
        }

        return new AlternativeToken($tokens);
    }
private function readAlternativeSentenceOrSingle ( $ input , & $ i ) { $ tokens = array ( ) ; while ( true ) { $ tokens [ ] = $ this -> readSentenceOrSingle ( $ input , $ i ) ; // end of input reached or end token found if ( ! isset ( $ input [ $ i ] ) || strpos ( '])' , $ input [ $ i ] ) !== false ) { break ; } // cursor now at alternative symbol (all other symbols are already handled) // skip alternative mark and continue with next alternative $ i ++ ; } // return a single token as-is if ( isset ( $ tokens [ 0 ] ) && ! isset ( $ tokens [ 1 ] ) ) { return $ tokens [ 0 ] ; } return new AlternativeToken ( $ tokens ) ; }
reads a complete sentence token until end of group

An "alternative sentence" may contain the following tokens:
- an alternative group (which may consist of individual sentences separated by `|`)
- a sentence (which may consist of multiple tokens)
- a single token

@param string $input
@param int $i
@throws InvalidArgumentException
@return TokenInterface
reads a complete sentence token until end of group