public function scss2Token()
{
static $srcpos = 0;
// current position in the source stream
static $srclen;
// the length of the source stream
$statement = '';
$token = null;
if (empty($srclen)) {
$srclen = strlen($this->source);
}
while ($token === null && $srcpos < strlen($this->source)) {
$c = $this->source[$srcpos++];
switch ($c) {
case self::BEGIN_COMMENT:
if (substr($this->source, $srcpos - 1, self::BEGIN_SASS_COMMENT_STRLEN) === self::BEGIN_SASS_COMMENT) {
while ($this->source[$srcpos++] !== "\n") {
if ($srcpos >= $srclen) {
throw new SassException('Unterminated commend', (object) array('source' => $statement, 'filename' => $this->filename, 'line' => $this->line));
}
}
$statement .= "\n";
} elseif (substr($this->source, $srcpos - 1, self::BEGIN_CSS_COMMENT_STRLEN) === self::BEGIN_CSS_COMMENT) {
if (ltrim($statement)) {
if ($this->debug) {
throw new SassException('Invalid comment', (object) array('source' => $statement, 'filename' => $this->filename, 'line' => $this->line));
}
}
$statement .= $c . $this->source[$srcpos++];
while (substr($this->source, $srcpos, self::END_CSS_COMMENT_STRLEN) !== self::END_CSS_COMMENT) {
$statement .= $this->source[$srcpos++];
}
$srcpos += self::END_CSS_COMMENT_STRLEN;
$token = $this->createToken($statement . self::END_CSS_COMMENT);
} else {
$statement .= $c;
}
break;
case self::DOUBLE_QUOTE:
case self::SINGLE_QUOTE:
$statement .= $c;
while (isset($this->source[$srcpos]) && $this->source[$srcpos] !== $c) {
$statement .= $this->source[$srcpos++];
}
if (isset($this->source[$srcpos + 1])) {
$statement .= $this->source[$srcpos++];
}
break;
case self::BEGIN_INTERPOLATION:
$statement .= $c;
if (substr($this->source, $srcpos - 1, self::BEGIN_INTERPOLATION_BLOCK_STRLEN) === self::BEGIN_INTERPOLATION_BLOCK) {
while ($this->source[$srcpos] !== self::END_BLOCK) {
$statement .= $this->source[$srcpos++];
}
$statement .= $this->source[$srcpos++];
}
break;
case self::BEGIN_BLOCK:
case self::END_BLOCK:
case self::END_STATEMENT:
$token = $this->createToken($statement . $c);
if ($token === null) {
$statement = '';
}
break;
default:
$statement .= $c;
break;
}
}
if ($token === null) {
$srclen = $srcpos = 0;
}
return $token;
}