in experiments/Lexer.php [524:573]
private function scanFloatingPointLiteral($text, & $pos, $endOfFilePos) {
$hasDot = false;
$expStart = null;
$hasSign = false;
while ($pos < $endOfFilePos) {
$char = $text[$pos];
if ($this->isDigitChar(ord($char))) {
$pos++;
continue;
} elseif ($char === ".") {
if ($hasDot || $expStart !== null) {
// Dot not valid, done scanning
break;
}
$hasDot = true;
$pos++;
continue;
} elseif ($char === "e" || $char === "E") {
if ($expStart !== null) {
// exponential not valid here, done scanning
break;
}
$expStart = $pos;
$pos++;
continue;
} elseif ($char === "+" || $char === "-") {
if ($expStart !== null && $expStart === $pos-1) {
$hasSign = true;
$pos++;
continue;
}
// sign not valid here, done scanning
break;
}
// unexpected character, done scanning
break;
}
if ($expStart !== null) {
$expectedMinPos = $hasSign ? $expStart + 3 : $expStart + 2;
if ($pos >= $expectedMinPos) {
return true;
}
// exponential is invalid, reset position
$pos = $expStart;
}
return $hasDot;
}