Implement numeric-separator (#4158)
JerryScript-DCO-1.0-Signed-off-by: bence gabor kis kisbg@inf.u-szeged.hu
This commit is contained in:
@@ -75,6 +75,7 @@ ecma_bigint_parse_string (const lit_utf8_byte_t *string_p, /**< string represena
|
||||
{
|
||||
ecma_bigint_digit_t radix = 10;
|
||||
uint32_t sign = (options & ECMA_BIGINT_PARSE_SET_NEGATIVE) ? ECMA_BIGINT_SIGN : 0;
|
||||
bool allow_underscore = options & ECMA_BIGINT_PARSE_ALLOW_UNDERSCORE;
|
||||
|
||||
const lit_utf8_byte_t *string_end_p = string_p + size;
|
||||
string_p = ecma_string_trim_front (string_p, string_p + size);
|
||||
@@ -120,7 +121,7 @@ ecma_bigint_parse_string (const lit_utf8_byte_t *string_p, /**< string represena
|
||||
return ECMA_BIGINT_ZERO;
|
||||
}
|
||||
|
||||
while (string_p < string_end_p && *string_p == LIT_CHAR_0)
|
||||
while (string_p < string_end_p && (*string_p == LIT_CHAR_0 || (*string_p == LIT_CHAR_UNDERSCORE && allow_underscore)))
|
||||
{
|
||||
string_p++;
|
||||
}
|
||||
@@ -140,6 +141,10 @@ ecma_bigint_parse_string (const lit_utf8_byte_t *string_p, /**< string represena
|
||||
{
|
||||
digit = (ecma_bigint_digit_t) (*string_p - LIT_CHAR_0);
|
||||
}
|
||||
else if (*string_p == LIT_CHAR_UNDERSCORE && allow_underscore)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
lit_utf8_byte_t character = (lit_utf8_byte_t) LEXER_TO_ASCII_LOWERCASE (*string_p);
|
||||
|
||||
@@ -36,6 +36,7 @@ typedef enum
|
||||
* return with ECMA_VALUE_FALSE */
|
||||
ECMA_BIGINT_PARSE_DISALLOW_MEMORY_ERROR = (1 << 2), /**< don't throw out-of-memory error,
|
||||
* return with ECMA_VALUE_NULL instead */
|
||||
ECMA_BIGINT_PARSE_ALLOW_UNDERSCORE = (1 << 3), /** allow parse underscore characters */
|
||||
} ecma_bigint_parse_string_options_t;
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user