src/Lexer.php
protected function match()
    {
        if ($this->position >= $this->length) {
            $this->stream[] = new Token(
                Tokens::T_EOF,
                null,
                $this->position
            );

            return false;
        }

        // if we don't get any matches move the position to the end of the file
        // and return true so we can get an EOF token on the next round.
        if (!preg_match($this->regex, $this->input, $matches, PREG_OFFSET_CAPTURE, $this->position)) {
            $this->position = $this->length;
            return true;
        }

        // if we're heare we found some tokens
        $c = count($matches);
        for ($i = 1; $i < $c; $i++) {
            if ('' === $matches[$i][0] || !isset($this->name_cache[$i-1])) {
                continue;
            }

            // move the position to our found offset
            $this->position = $matches[$i][1];

            $this->stream[] = new Token(
                $this->name_cache[$i-1],
                $matches[$i][0],
                $this->position
            );

            break;
        }

        $this->position += strlen($matches[0][0]);

        return true;
    }
protected function match()
    {
        if ($this->position >= $this->length) {
            $this->stream[] = new Token(
                Tokens::T_EOF,
                null,
                $this->position
            );

            return false;
        }

        // if we don't get any matches move the position to the end of the file
        // and return true so we can get an EOF token on the next round.
        if (!preg_match($this->regex, $this->input, $matches, PREG_OFFSET_CAPTURE, $this->position)) {
            $this->position = $this->length;
            return true;
        }

        // if we're heare we found some tokens
        $c = count($matches);
        for ($i = 1; $i < $c; $i++) {
            if ('' === $matches[$i][0] || !isset($this->name_cache[$i-1])) {
                continue;
            }

            // move the position to our found offset
            $this->position = $matches[$i][1];

            $this->stream[] = new Token(
                $this->name_cache[$i-1],
                $matches[$i][0],
                $this->position
            );

            break;
        }

        $this->position += strlen($matches[0][0]);

        return true;
    }
Search for a match with our regex (created in the constructor). Only
returns the first match.

@since   0.1
@access  public
@return  boolean