public function loopScan($scanners, $required = false)
    {
        while ($this->reader->hasLength()) {
            $success = false;
            foreach ($this->scan($scanners) as $token) {
                $success = true;
                yield $token;
            }

            if (!$success) {
                break;
            }
        }

        if ($this->reader->hasLength() && $required) {
            $this->throwException(
                'Unexpected '.$this->reader->peek(20)
            );
        }
    }
public function loopScan($scanners, $required = false)
    {
        while ($this->reader->hasLength()) {
            $success = false;
            foreach ($this->scan($scanners) as $token) {
                $success = true;
                yield $token;
            }

            if (!$success) {
                break;
            }
        }

        if ($this->reader->hasLength() && $required) {
            $this->throwException(
                'Unexpected '.$this->reader->peek(20)
            );
        }
    }
public function loopScan ( $ scanners , $ required = false ) { while ( $ this -> reader -> hasLength ( ) ) { $ success = false ; foreach ( $ this -> scan ( $ scanners ) as $ token ) { $ success = true ; yield $ token ; } if ( ! $ success ) { break ; } } if ( $ this -> reader -> hasLength ( ) && $ required ) { $ this -> throwException ( 'Unexpected ' . $ this -> reader -> peek ( 20 ) ) ; } }
Continuously scans with all scanners passed as the first argument.

If the second argument is true, it will throw an exception if none of the scanners
produced any valid tokens. The reading also stops when the end of the input as been reached.

@param $scanners
@param bool $required

@throws LexerException

@return \Generator
Continuously scans with all scanners passed as the first argument .