protected function tryParseScalar()
{
$this->skipSpaces();
if ($this->cur() == "'") {
$this->advance();
$p = $this->p;
while (!$this->metEnd()) {
$this->advance();
if ($this->cur() == "'") {
$pos = $this->p;
$this->advance();
if ($this->cur() != "'") {
$this->rollback($pos);
break;
}
}
}
$string = str_replace("''", "'", substr($this->str, $p, $this->p - 1 - $p));
return new Token('string', $string);
} elseif (preg_match('/-?\\d+ \\. \\d+/x', substr($this->str, $this->p), $matches)) {
$this->p += strlen($matches[0]);
return new Token('double', doubleval($matches[0]));
} elseif (preg_match('/-?\\d+/x', substr($this->str, $this->p), $matches)) {
$this->p += strlen($matches[0]);
return new Token('int', intval($matches[0]));
}
}