mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 17:27:35 +00:00
LibJS+LibCrypto: Allow '_' as a numeric literal separator :^)
This patch adds support for the NumericLiteralSeparator concept from the ECMAScript grammar.
This commit is contained in:
parent
527c639c1f
commit
49018553d3
4 changed files with 61 additions and 15 deletions
|
@ -53,7 +53,16 @@ TokenCategory Token::category() const
|
|||
double Token::double_value() const
|
||||
{
|
||||
VERIFY(type() == TokenType::NumericLiteral);
|
||||
String value_string(m_value);
|
||||
|
||||
StringBuilder builder;
|
||||
|
||||
for (auto ch : m_value) {
|
||||
if (ch == '_')
|
||||
continue;
|
||||
builder.append(ch);
|
||||
}
|
||||
|
||||
String value_string = builder.to_string();
|
||||
if (value_string[0] == '0' && value_string.length() >= 2) {
|
||||
if (value_string[1] == 'x' || value_string[1] == 'X') {
|
||||
// hexadecimal
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue