private function readNumber($start, $firstCode, $line, $col, Token $prev)
{
$code = $firstCode;
$body = $this->source->body;
$position = $start;
$isFloat = false;
if ($code === 45) {
// -
$code = Utils::charCodeAt($body, ++$position);
}
// guard against leading zero's
if ($code === 48) {
// 0
$code = Utils::charCodeAt($body, ++$position);
if ($code >= 48 && $code <= 57) {
throw new SyntaxError($this->source, $position, "Invalid number, unexpected digit after 0: " . Utils::printCharCode($code));
}
} else {
$position = $this->readDigits($position, $code);
$code = Utils::charCodeAt($body, $position);
}
if ($code === 46) {
// .
$isFloat = true;
$code = Utils::charCodeAt($body, ++$position);
$position = $this->readDigits($position, $code);
$code = Utils::charCodeAt($body, $position);
}
if ($code === 69 || $code === 101) {
// E e
$isFloat = true;
$code = Utils::charCodeAt($body, ++$position);
if ($code === 43 || $code === 45) {
// + -
$code = Utils::charCodeAt($body, ++$position);
}
$position = $this->readDigits($position, $code);
}
return new Token($isFloat ? Token::FLOAT : Token::INT, $start, $position, $line, $col, $prev, mb_substr($body, $start, $position - $start, 'UTF-8'));
}