summaryrefslogtreecommitdiff
path: root/Libraries/LibJS/Token.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Libraries/LibJS/Token.cpp')
-rw-r--r--Libraries/LibJS/Token.cpp24
1 files changed, 21 insertions, 3 deletions
diff --git a/Libraries/LibJS/Token.cpp b/Libraries/LibJS/Token.cpp
index f698cef1cb..c91051a611 100644
--- a/Libraries/LibJS/Token.cpp
+++ b/Libraries/LibJS/Token.cpp
@@ -35,9 +35,9 @@ namespace JS {
const char* Token::name(TokenType type)
{
switch (type) {
-#define __ENUMERATE_JS_TOKEN(x) \
- case TokenType::x: \
- return #x;
+#define __ENUMERATE_JS_TOKEN(type, category) \
+ case TokenType::type: \
+ return #type;
ENUMERATE_JS_TOKENS
#undef __ENUMERATE_JS_TOKEN
default:
@@ -51,6 +51,24 @@ const char* Token::name() const
return name(m_type);
}
+TokenCategory Token::category(TokenType type)
+{
+ switch (type) {
+#define __ENUMERATE_JS_TOKEN(type, category) \
+ case TokenType::type: \
+ return TokenCategory::category;
+ ENUMERATE_JS_TOKENS
+#undef __ENUMERATE_JS_TOKEN
+ default:
+ ASSERT_NOT_REACHED();
+ }
+}
+
+TokenCategory Token::category() const
+{
+ return category(m_type);
+}
+
double Token::double_value() const
{
ASSERT(type() == TokenType::NumericLiteral);