Fixed issue with binary literal

This commit is contained in:
Steve Tautonico 2023-10-08 04:11:03 -04:00
parent badc8d44d1
commit 23f1c6e941
No known key found for this signature in database
GPG Key ID: 6422E5D217FC628B

View File

@ -293,13 +293,13 @@ static bool is_unicode_Lo_char(uint32_t c) {
PK_ASSERT(base == 10);
add_token(TK("@num"), Number::stof(m[0], &size));
} else {
// If we're base 8, chop off the "o"
// If we're base 8/2, chop off the "o"
std::string match = m[0].str();
if (base == 8) match.erase(1, 1);
if (base == 8 || base == 2) match.erase(1, 1);
add_token(TK("@num"), (i64)std::stoll(match, &size, base));
}
// HACK: We need to check length-1 for octal since python octals are "0o..." and c/c++ octals are "0..."
if (base == 8) {PK_ASSERT((int)size == (int)m.length()-1);}
if (base == 8 || base == 2) {PK_ASSERT((int)size == (int)m.length()-1);}
else {PK_ASSERT((int)size == (int)m.length());}
}catch(...){
SyntaxError("invalid number literal");