protected function sequenceMatches($sequence) {
        $len = strlen($sequence);
        $buffer = '';
        for ($i = 0; $i < $len; ++$i) {
            $buffer .= $this->scanner->current();

            // EOF. Rewind and let the caller handle it.
            if ($this->scanner->current() === false) {
                $this->scanner->unconsume($i);
                return false;
            }
            $this->scanner->next();
        }

        $this->scanner->unconsume($len);
        return $buffer == $sequence;
    }