Lexer: Do not allow leading zero for number type

This commit is contained in:
Tomas Babej 2021-01-24 01:28:54 -05:00
parent b9bc0f8c87
commit 6a33bb8656

View file

@ -608,7 +608,8 @@ bool Lexer::isHexNumber (std::string& token, Lexer::Type& type)
////////////////////////////////////////////////////////////////////////////////
// Lexer::Type::number
// \d+
// 0
// [1-9]\d*
// [ . \d+ ]
// [ e|E [ +|- ] \d+ [ . \d+ ] ]
// not followed by non-operator.
@ -616,9 +617,16 @@ bool Lexer::isNumber (std::string& token, Lexer::Type& type)
{
std::size_t marker = _cursor;
bool leading_zero = (_text[marker] == '0');
if (unicodeLatinDigit (_text[marker]))
{
++marker;
// Two (or more) digit number with a leading zero are not allowed
if (leading_zero && unicodeLatinDigit (_text[marker]))
return false;
while (unicodeLatinDigit (_text[marker]))
utf8_next_char (_text, marker);