diff options
author | Idan Horowitz <idan.horowitz@gmail.com> | 2021-06-14 02:19:23 +0300 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2021-06-14 01:45:04 +0100 |
commit | 690eb3bb8a538e9773024f40e8b4676336c8f849 (patch) | |
tree | 6e2c1f50d793649439170f51ab870650e9da410d /Userland/Libraries/LibJS/Lexer.cpp | |
parent | 2ad2e055e28de3c1a6a8d1a1c9953a4cd0016636 (diff) | |
download | serenity-690eb3bb8a538e9773024f40e8b4676336c8f849.zip |
LibJS: Add support for hex, octal & binary big integer literals
Diffstat (limited to 'Userland/Libraries/LibJS/Lexer.cpp')
-rw-r--r-- | Userland/Libraries/LibJS/Lexer.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/Userland/Libraries/LibJS/Lexer.cpp b/Userland/Libraries/LibJS/Lexer.cpp index 904a221e96..cf4c052072 100644 --- a/Userland/Libraries/LibJS/Lexer.cpp +++ b/Userland/Libraries/LibJS/Lexer.cpp @@ -466,12 +466,24 @@ Token Lexer::next() } else if (m_current_char == 'o' || m_current_char == 'O') { // octal is_invalid_numeric_literal = !consume_octal_number(); + if (m_current_char == 'n') { + consume(); + token_type = TokenType::BigIntLiteral; + } } else if (m_current_char == 'b' || m_current_char == 'B') { // binary is_invalid_numeric_literal = !consume_binary_number(); + if (m_current_char == 'n') { + consume(); + token_type = TokenType::BigIntLiteral; + } } else if (m_current_char == 'x' || m_current_char == 'X') { // hexadecimal is_invalid_numeric_literal = !consume_hexadecimal_number(); + if (m_current_char == 'n') { + consume(); + token_type = TokenType::BigIntLiteral; + } } else if (m_current_char == 'n') { consume(); token_type = TokenType::BigIntLiteral; |