Lexer.php
protected function scanToken($type, $pattern, $modifiers = '')
    {

        if (!$this->match($pattern, $modifiers))
            return;

        $this->consumeMatch();
        $token = $this->createToken($type);
        foreach ($this->lastMatches as $key => $value) {

            //We append all STRING-Matches (?<name>) to the token
            if (is_string($key)) {

                $token[$key] = empty($value) ? null : $value;
            }
        }

        yield $token;
    }
protected function scanToken($type, $pattern, $modifiers = '')
    {

        if (!$this->match($pattern, $modifiers))
            return;

        $this->consumeMatch();
        $token = $this->createToken($type);
        foreach ($this->lastMatches as $key => $value) {

            //We append all STRING-Matches (?<name>) to the token
            if (is_string($key)) {

                $token[$key] = empty($value) ? null : $value;
            }
        }

        yield $token;
    }
protected function scanToken ( $ type , $ pattern , $ modifiers = '' ) { if ( ! $ this -> match ( $ pattern , $ modifiers ) ) return ; $ this -> consumeMatch ( ) ; $ token = $ this -> createToken ( $ type ) ; foreach ( $ this -> lastMatches as $ key => $ value ) { //We append all STRING-Matches (?<name>) to the token if ( is_string ( $ key ) ) { $ token [ $ key ] = empty ( $ value ) ? null : $ value ; } } yield $ token ; }
Scans for a specific token-type based on a pattern
and converts it to a valid token automatically.

All matches that have a name (RegEx (?<name>...)-directive
will directly get a key with that name and value
on the token array

For matching, ->match() is used internally

@see Lexer->match

@param string $type      the token type to create, if matched
@param string $pattern   the pattern to match
@param string $modifiers the regex-modifiers for the pattern

@return \Generator
Scans for a specific token - type based on a pattern and converts it to a valid token automatically .