summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibJS/Lexer.cpp
diff options
context:
space:
mode:
authorIdan Horowitz <idan.horowitz@gmail.com>2021-06-14 02:19:23 +0300
committerLinus Groh <mail@linusgroh.de>2021-06-14 01:45:04 +0100
commit690eb3bb8a538e9773024f40e8b4676336c8f849 (patch)
tree6e2c1f50d793649439170f51ab870650e9da410d /Userland/Libraries/LibJS/Lexer.cpp
parent2ad2e055e28de3c1a6a8d1a1c9953a4cd0016636 (diff)
downloadserenity-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.cpp12
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;