Bug 1427710 part 1 - Make TokenKind an enum class. r=jandem
authorRofael Aleezada <me@rofael.com>
Fri, 12 Jan 2018 15:16:12 +0100
changeset 453321 5eb4b2bdb7cd9acd4dac829bc930142d1f3b6d33
parent 453320 7c92680e18dbc44de8b2bb5efbb23c686e0fc504
child 453322 b3046ae63cbfbbd1ef6d0588e97f3c2a5321b0c2
push id1648
push usermtabara@mozilla.com
push dateThu, 01 Mar 2018 12:45:47 +0000
treeherdermozilla-release@cbb9688c2eeb [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjandem
bugs1427710
milestone59.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1427710 part 1 - Make TokenKind an enum class. r=jandem
js/src/frontend/Parser.cpp
js/src/frontend/Parser.h
js/src/frontend/ReservedWords.h
js/src/frontend/TokenKind.h
js/src/frontend/TokenStream.cpp
js/src/frontend/TokenStream.h
js/src/wasm/AsmJS.cpp
--- a/js/src/frontend/Parser.cpp
+++ b/js/src/frontend/Parser.cpp
@@ -1000,17 +1000,17 @@ GeneralParser<ParseHandler, CharT>::pars
 
     Node pn = statementList(YieldIsName);
     if (!pn)
         return null();
 
     TokenKind tt;
     if (!tokenStream.getToken(&tt, TokenStream::Operand))
         return null();
-    if (tt != TOK_EOF) {
+    if (tt != TokenKind::TOK_EOF) {
         error(JSMSG_GARBAGE_AFTER_INPUT, "script", TokenKindToDesc(tt));
         return null();
     }
     if (foldConstants) {
         if (!FoldConstants(context, &pn, this))
             return null();
     }
 
@@ -1020,23 +1020,23 @@ GeneralParser<ParseHandler, CharT>::pars
 /*
  * Strict mode forbids introducing new definitions for 'eval', 'arguments',
  * 'let', 'static', 'yield', or for any strict mode reserved word.
  */
 bool
 ParserBase::isValidStrictBinding(PropertyName* name)
 {
     TokenKind tt = ReservedWordTokenKind(name);
-    if (tt == TOK_NAME) {
+    if (tt == TokenKind::TOK_NAME) {
         return name != context->names().eval &&
                name != context->names().arguments;
     }
-    return tt != TOK_LET &&
-           tt != TOK_STATIC &&
-           tt != TOK_YIELD &&
+    return tt != TokenKind::TOK_LET &&
+           tt != TokenKind::TOK_STATIC &&
+           tt != TokenKind::TOK_YIELD &&
            !TokenKindIsStrictReservedWord(tt);
 }
 
 /*
  * Returns true if all parameter names are valid strict mode binding names and
  * no duplicate parameter names are present.
  */
 bool
@@ -1697,22 +1697,22 @@ PerHandlerParser<ParseHandler>::propagat
 
 template <typename CharT>
 bool
 Parser<FullParseHandler, CharT>::checkStatementsEOF()
 {
     // This is designed to be paired with parsing a statement list at the top
     // level.
     //
-    // The statementList() call breaks on TOK_RC, so make sure we've
+    // The statementList() call breaks on TokenKind::TOK_RC, so make sure we've
     // reached EOF here.
     TokenKind tt;
     if (!tokenStream.peekToken(&tt, TokenStream::Operand))
         return false;
-    if (tt != TOK_EOF) {
+    if (tt != TokenKind::TOK_EOF) {
         error(JSMSG_UNEXPECTED_TOKEN, "expression", TokenKindToDesc(tt));
         return false;
     }
     return true;
 }
 
 template <typename Scope>
 typename Scope::Data*
@@ -2271,17 +2271,17 @@ Parser<FullParseHandler, CharT>::moduleB
         return null();
 
     MOZ_ASSERT(pn->isKind(ParseNodeKind::StatementList));
     mn->pn_body = pn;
 
     TokenKind tt;
     if (!tokenStream.getToken(&tt, TokenStream::Operand))
         return null();
-    if (tt != TOK_EOF) {
+    if (tt != TokenKind::TOK_EOF) {
         error(JSMSG_GARBAGE_AFTER_INPUT, "module", TokenKindToDesc(tt));
         return null();
     }
 
     if (!modulesc->builder.buildTables())
         return null();
 
     // Check exported local bindings exist and mark them as closed over.
@@ -2550,26 +2550,26 @@ Parser<FullParseHandler, CharT>::standal
 {
     MOZ_ASSERT(checkOptionsCalled);
 
     // Skip prelude.
     TokenKind tt;
     if (!tokenStream.getToken(&tt, TokenStream::Operand))
         return null();
     if (asyncKind == FunctionAsyncKind::AsyncFunction) {
-        MOZ_ASSERT(tt == TOK_ASYNC);
+        MOZ_ASSERT(tt == TokenKind::TOK_ASYNC);
         if (!tokenStream.getToken(&tt, TokenStream::Operand))
             return null();
     }
-    MOZ_ASSERT(tt == TOK_FUNCTION);
+    MOZ_ASSERT(tt == TokenKind::TOK_FUNCTION);
 
     if (!tokenStream.getToken(&tt))
         return null();
     if (generatorKind == GeneratorKind::Generator) {
-        MOZ_ASSERT(tt == TOK_MUL);
+        MOZ_ASSERT(tt == TokenKind::TOK_MUL);
         if (!tokenStream.getToken(&tt))
             return null();
     }
 
     // Skip function name, if present.
     if (TokenKindIsPossibleIdentifierName(tt)) {
         MOZ_ASSERT(anyChars.currentName() == fun->explicitName());
     } else {
@@ -2603,17 +2603,17 @@ Parser<FullParseHandler, CharT>::standal
     if (!functionFormalParametersAndBody(InAllowed, yieldHandling, fn, Statement,
                                          parameterListEnd, /* isStandaloneFunction = */ true))
     {
         return null();
     }
 
     if (!tokenStream.getToken(&tt, TokenStream::Operand))
         return null();
-    if (tt != TOK_EOF) {
+    if (tt != TokenKind::TOK_EOF) {
         error(JSMSG_GARBAGE_AFTER_INPUT, "function body", TokenKindToDesc(tt));
         return null();
     }
 
     if (!FoldConstants(context, &fn, this))
         return null();
 
     return fn;
@@ -2860,48 +2860,52 @@ ParserBase::newFunction(HandleAtom atom,
     }
     return fun;
 }
 
 template <class ParseHandler, typename CharT>
 bool
 GeneralParser<ParseHandler, CharT>::matchOrInsertSemicolon()
 {
-    TokenKind tt = TOK_EOF;
+    TokenKind tt = TokenKind::TOK_EOF;
     if (!tokenStream.peekTokenSameLine(&tt, TokenStream::Operand))
         return false;
-    if (tt != TOK_EOF && tt != TOK_EOL && tt != TOK_SEMI && tt != TOK_RC) {
+    if (tt != TokenKind::TOK_EOF &&
+        tt != TokenKind::TOK_EOL &&
+        tt != TokenKind::TOK_SEMI &&
+        tt != TokenKind::TOK_RC)
+    {
         /*
          * When current token is `await` and it's outside of async function,
          * it's possibly intended to be an await expression.
          *
          *   await f();
          *        ^
          *        |
          *        tried to insert semicolon here
          *
          * Detect this situation and throw an understandable error.  Otherwise
          * we'd throw a confusing "unexpected token: (unexpected token)" error.
          */
-        if (!pc->isAsync() && anyChars.currentToken().type == TOK_AWAIT) {
+        if (!pc->isAsync() && anyChars.currentToken().type == TokenKind::TOK_AWAIT) {
             error(JSMSG_AWAIT_OUTSIDE_ASYNC);
             return false;
         }
-        if (!yieldExpressionsSupported() && anyChars.currentToken().type == TOK_YIELD) {
+        if (!yieldExpressionsSupported() && anyChars.currentToken().type == TokenKind::TOK_YIELD) {
             error(JSMSG_YIELD_OUTSIDE_GENERATOR);
             return false;
         }
 
         /* Advance the scanner for proper error location reporting. */
         tokenStream.consumeKnownToken(tt, TokenStream::Operand);
         error(JSMSG_UNEXPECTED_TOKEN_NO_EXPECT, TokenKindToDesc(tt));
         return false;
     }
     bool matched;
-    return tokenStream.matchToken(&matched, TOK_SEMI, TokenStream::Operand);
+    return tokenStream.matchToken(&matched, TokenKind::TOK_SEMI, TokenStream::Operand);
 }
 
 bool
 ParserBase::leaveInnerFunction(ParseContext* outerpc)
 {
     MOZ_ASSERT(pc != outerpc);
 
     // If the current function allows super.property but cannot have a home
@@ -2995,17 +2999,17 @@ GeneralParser<ParseHandler, CharT>::func
         }
     }
 
     TokenPos firstTokenPos;
     if (!parenFreeArrow) {
         TokenKind tt;
         if (!tokenStream.getToken(&tt, firstTokenModifier))
             return false;
-        if (tt != TOK_LP) {
+        if (tt != TokenKind::TOK_LP) {
             error(kind == Arrow ? JSMSG_BAD_ARROW_ARGS : JSMSG_PAREN_BEFORE_FORMAL);
             return false;
         }
 
         firstTokenPos = pos();
 
         // Record the start of function source (for FunctionToString). If we
         // are parenFreeArrow, we will set this below, after consuming the NAME.
@@ -3022,17 +3026,17 @@ GeneralParser<ParseHandler, CharT>::func
         return false;
     handler.setFunctionFormalParametersAndBody(funcpn, argsbody);
 
     bool hasArguments = false;
     if (parenFreeArrow) {
         hasArguments = true;
     } else {
         bool matched;
-        if (!tokenStream.matchToken(&matched, TOK_RP, TokenStream::Operand))
+        if (!tokenStream.matchToken(&matched, TokenKind::TOK_RP, TokenStream::Operand))
             return false;
         if (!matched)
             hasArguments = true;
     }
     if (hasArguments) {
         bool hasRest = false;
         bool hasDefault = false;
         bool duplicatedParam = false;
@@ -3051,17 +3055,17 @@ GeneralParser<ParseHandler, CharT>::func
             }
 
             TokenKind tt;
             if (!tokenStream.getToken(&tt, argModifier))
                 return false;
             argModifier = TokenStream::Operand;
             MOZ_ASSERT_IF(parenFreeArrow, TokenKindIsPossibleIdentifier(tt));
 
-            if (tt == TOK_TRIPLEDOT) {
+            if (tt == TokenKind::TOK_TRIPLEDOT) {
                 if (IsSetterKind(kind)) {
                     error(JSMSG_ACCESSOR_WRONG_ARGS, "setter", "one", "");
                     return false;
                 }
 
                 disallowDuplicateParams = true;
                 if (duplicatedParam) {
                     // Has duplicated args before the rest parameter.
@@ -3070,25 +3074,28 @@ GeneralParser<ParseHandler, CharT>::func
                 }
 
                 hasRest = true;
                 funbox->setHasRest();
 
                 if (!tokenStream.getToken(&tt))
                     return false;
 
-                if (!TokenKindIsPossibleIdentifier(tt) && tt != TOK_LB && tt != TOK_LC) {
+                if (!TokenKindIsPossibleIdentifier(tt) &&
+                    tt != TokenKind::TOK_LB &&
+                    tt != TokenKind::TOK_LC)
+                {
                     error(JSMSG_NO_REST_NAME);
                     return false;
                 }
             }
 
             switch (tt) {
-              case TOK_LB:
-              case TOK_LC: {
+              case TokenKind::TOK_LB:
+              case TokenKind::TOK_LC: {
                 disallowDuplicateParams = true;
                 if (duplicatedParam) {
                     // Has duplicated args before the destructuring parameter.
                     error(JSMSG_BAD_DUP_ARGS);
                     return false;
                 }
 
                 funbox->hasDestructuringArgs = true;
@@ -3140,17 +3147,17 @@ GeneralParser<ParseHandler, CharT>::func
             // parentheses-free arrow function, |a => ...|, the '=' necessary
             // for a default expression would really be an assignment operator:
             // that is, |a = b => 42;| would parse as |a = (b => 42);|.  So we
             // should stop parsing arguments here.
             if (parenFreeArrow)
                 break;
 
             bool matched;
-            if (!tokenStream.matchToken(&matched, TOK_ASSIGN, TokenStream::Operand))
+            if (!tokenStream.matchToken(&matched, TokenKind::TOK_ASSIGN, TokenStream::Operand))
                 return false;
             if (matched) {
                 // A default argument without parentheses would look like:
                 // a = expr => body, but both operators are right-associative, so
                 // that would have been parsed as a = (expr => body) instead.
                 // Therefore it's impossible to get here with parenFreeArrow.
                 MOZ_ASSERT(!parenFreeArrow);
 
@@ -3179,34 +3186,34 @@ GeneralParser<ParseHandler, CharT>::func
                 if (!handler.setLastFunctionFormalParameterDefault(funcpn, def_expr))
                     return false;
             }
 
             // Setter syntax uniquely requires exactly one argument.
             if (IsSetterKind(kind))
                 break;
 
-            if (!tokenStream.matchToken(&matched, TOK_COMMA, TokenStream::Operand))
+            if (!tokenStream.matchToken(&matched, TokenKind::TOK_COMMA, TokenStream::Operand))
                 return false;
             if (!matched)
                 break;
 
             if (!hasRest) {
                 if (!tokenStream.peekToken(&tt, TokenStream::Operand))
                     return null();
-                if (tt == TOK_RP)
+                if (tt == TokenKind::TOK_RP)
                     break;
             }
         }
 
         if (!parenFreeArrow) {
             TokenKind tt;
             if (!tokenStream.getToken(&tt, TokenStream::Operand))
                 return false;
-            if (tt != TOK_RP) {
+            if (tt != TokenKind::TOK_RP) {
                 if (IsSetterKind(kind)) {
                     error(JSMSG_ACCESSOR_WRONG_ARGS, "setter", "one", "");
                     return false;
                 }
 
                 error(JSMSG_PAREN_AFTER_FORMAL);
                 return false;
             }
@@ -3299,17 +3306,17 @@ GeneralParser<ParseHandler, CharT>::addE
     Node pn = expr(InAllowed, yieldHandling, TripledotProhibited);
     if (!pn)
         return false;
     handler.addList(nodeList, pn);
 
     TokenKind tt;
     if (!tokenStream.getToken(&tt, TokenStream::Operand))
         return false;
-    if (tt != TOK_RC) {
+    if (tt != TokenKind::TOK_RC) {
         error(JSMSG_TEMPLSTR_UNTERM_EXPR);
         return false;
     }
 
     return tokenStream.getToken(ttp, TokenStream::TemplateTail);
 }
 
 template <class ParseHandler, typename CharT>
@@ -3320,17 +3327,17 @@ GeneralParser<ParseHandler, CharT>::tagg
     Node callSiteObjNode = handler.newCallSiteObject(pos().begin);
     if (!callSiteObjNode)
         return false;
     handler.addList(nodeList, callSiteObjNode);
 
     while (true) {
         if (!appendToCallSiteObj(callSiteObjNode))
             return false;
-        if (tt != TOK_TEMPLATE_HEAD)
+        if (tt != TokenKind::TOK_TEMPLATE_HEAD)
             break;
 
         if (!addExprAndGetNextTemplStrToken(yieldHandling, nodeList, &tt))
             return false;
     }
     handler.setEndPosition(nodeList, callSiteObjNode);
     return true;
 }
@@ -3352,17 +3359,17 @@ GeneralParser<ParseHandler, CharT>::temp
         if (!addExprAndGetNextTemplStrToken(yieldHandling, nodeList, &tt))
             return null();
 
         pn = noSubstitutionUntaggedTemplate();
         if (!pn)
             return null();
 
         handler.addList(nodeList, pn);
-    } while (tt == TOK_TEMPLATE_HEAD);
+    } while (tt == TokenKind::TOK_TEMPLATE_HEAD);
     return nodeList;
 }
 
 template <class ParseHandler, typename CharT>
 typename ParseHandler::Node
 GeneralParser<ParseHandler, CharT>::functionDefinition(Node funcNode, uint32_t toStringStart,
                                                        InHandling inHandling, YieldHandling yieldHandling,
                                                        HandleAtom funName, FunctionSyntaxKind kind,
@@ -3737,17 +3744,17 @@ GeneralParser<ParseHandler, CharT>::func
         if (!varScope->init(pc))
             return false;
     } else {
         pc->functionScope().useAsVarScope(pc);
     }
 
     if (kind == Arrow) {
         bool matched;
-        if (!tokenStream.matchToken(&matched, TOK_ARROW))
+        if (!tokenStream.matchToken(&matched, TokenKind::TOK_ARROW))
             return false;
         if (!matched) {
             error(JSMSG_BAD_ARROW_ARGS);
             return false;
         }
     }
 
     // When parsing something for new Function() we have to make sure to
@@ -3758,17 +3765,17 @@ GeneralParser<ParseHandler, CharT>::func
     }
 
     // Parse the function body.
     FunctionBodyType bodyType = StatementListBody;
     TokenKind tt;
     if (!tokenStream.getToken(&tt, TokenStream::Operand))
         return false;
     uint32_t openedPos = 0;
-    if (tt != TOK_LC) {
+    if (tt != TokenKind::TOK_LC) {
         if (kind != Arrow) {
             if (funbox->isGenerator() || funbox->isAsync() || kind == Method ||
                 kind == GetterNoExpressionClosure || kind == SetterNoExpressionClosure ||
                 IsConstructorKind(kind) || kind == PrimaryExpression)
             {
                 error(JSMSG_CURLY_BEFORE_BODY);
                 return false;
             }
@@ -3832,17 +3839,17 @@ GeneralParser<ParseHandler, CharT>::func
         // we don't need call AutoAwaitIsKeyword here.
 
         uint32_t nameOffset = handler.getFunctionNameOffset(pn, anyChars);
         if (!checkBindingIdentifier(propertyName, nameOffset, nameYieldHandling))
             return false;
     }
 
     if (bodyType == StatementListBody) {
-        MUST_MATCH_TOKEN_MOD_WITH_REPORT(TOK_RC, TokenStream::Operand,
+        MUST_MATCH_TOKEN_MOD_WITH_REPORT(TokenKind::TOK_RC, TokenStream::Operand,
                                          reportMissingClosing(JSMSG_CURLY_AFTER_BODY,
                                                               JSMSG_CURLY_OPENED, openedPos));
         funbox->setEnd(anyChars);
     } else {
 #if !JS_HAS_EXPR_CLOSURES
         MOZ_ASSERT(kind == Arrow);
 #endif
         if (anyChars.hadError())
@@ -3867,17 +3874,17 @@ GeneralParser<ParseHandler, CharT>::func
 
 template <class ParseHandler, typename CharT>
 typename ParseHandler::Node
 GeneralParser<ParseHandler, CharT>::functionStmt(uint32_t toStringStart,
                                                  YieldHandling yieldHandling,
                                                  DefaultHandling defaultHandling,
                                                  FunctionAsyncKind asyncKind)
 {
-    MOZ_ASSERT(anyChars.isCurrentTokenType(TOK_FUNCTION));
+    MOZ_ASSERT(anyChars.isCurrentTokenType(TokenKind::TOK_FUNCTION));
 
     // In sloppy mode, Annex B.3.2 allows labelled function declarations.
     // Otherwise it's a parse error.
     ParseContext::Statement* declaredInStmt = pc->innermostStatement();
     if (declaredInStmt && declaredInStmt->kind() == StatementKind::Label) {
         MOZ_ASSERT(!pc->sc()->strict(),
                    "labeled functions shouldn't be parsed in strict mode");
 
@@ -3893,17 +3900,17 @@ GeneralParser<ParseHandler, CharT>::func
         }
     }
 
     TokenKind tt;
     if (!tokenStream.getToken(&tt))
         return null();
 
     GeneratorKind generatorKind = GeneratorKind::NotGenerator;
-    if (tt == TOK_MUL) {
+    if (tt == TokenKind::TOK_MUL) {
         generatorKind = GeneratorKind::Generator;
         if (!tokenStream.getToken(&tt))
             return null();
     }
 
     RootedPropertyName name(context);
     if (TokenKindIsPossibleIdentifier(tt)) {
         name = bindingIdentifier(yieldHandling);
@@ -3958,25 +3965,25 @@ GeneralParser<ParseHandler, CharT>::func
 
 template <class ParseHandler, typename CharT>
 typename ParseHandler::Node
 GeneralParser<ParseHandler, CharT>::functionExpr(uint32_t toStringStart,
                                                  ExpressionClosure expressionClosureHandling,
                                                  InvokedPrediction invoked,
                                                  FunctionAsyncKind asyncKind)
 {
-    MOZ_ASSERT(anyChars.isCurrentTokenType(TOK_FUNCTION));
+    MOZ_ASSERT(anyChars.isCurrentTokenType(TokenKind::TOK_FUNCTION));
 
     AutoAwaitIsKeyword<ParseHandler, CharT> awaitIsKeyword(this, GetAwaitHandling(asyncKind));
     GeneratorKind generatorKind = GeneratorKind::NotGenerator;
     TokenKind tt;
     if (!tokenStream.getToken(&tt))
         return null();
 
-    if (tt == TOK_MUL) {
+    if (tt == TokenKind::TOK_MUL) {
         generatorKind = GeneratorKind::Generator;
         if (!tokenStream.getToken(&tt))
             return null();
     }
 
     YieldHandling yieldHandling = GetYieldHandling(generatorKind);
 
     RootedPropertyName name(context);
@@ -4182,23 +4189,23 @@ GeneralParser<ParseHandler, CharT>::stat
 
     bool canHaveDirectives = pc->atBodyLevel();
     if (canHaveDirectives)
         anyChars.clearSawOctalEscape();
     bool afterReturn = false;
     bool warnedAboutStatementsAfterReturn = false;
     uint32_t statementBegin = 0;
     for (;;) {
-        TokenKind tt = TOK_EOF;
+        TokenKind tt = TokenKind::TOK_EOF;
         if (!tokenStream.peekToken(&tt, TokenStream::Operand)) {
             if (anyChars.isEOF())
                 isUnexpectedEOF_ = true;
             return null();
         }
-        if (tt == TOK_EOF || tt == TOK_RC) {
+        if (tt == TokenKind::TOK_EOF || tt == TokenKind::TOK_RC) {
             TokenPos pos;
             if (!tokenStream.peekTokenPos(&pos, TokenStream::Operand)) {
                 return null();
             }
             handler.setListEndPosition(pn, pos);
             break;
         }
         if (afterReturn) {
@@ -4234,38 +4241,38 @@ GeneralParser<ParseHandler, CharT>::stat
 
     return pn;
 }
 
 template <class ParseHandler, typename CharT>
 typename ParseHandler::Node
 GeneralParser<ParseHandler, CharT>::condition(InHandling inHandling, YieldHandling yieldHandling)
 {
-    MUST_MATCH_TOKEN(TOK_LP, JSMSG_PAREN_BEFORE_COND);
+    MUST_MATCH_TOKEN(TokenKind::TOK_LP, JSMSG_PAREN_BEFORE_COND);
 
     Node pn = exprInParens(inHandling, yieldHandling, TripledotProhibited);
     if (!pn)
         return null();
 
-    MUST_MATCH_TOKEN_MOD(TOK_RP, TokenStream::Operand, JSMSG_PAREN_AFTER_COND);
+    MUST_MATCH_TOKEN_MOD(TokenKind::TOK_RP, TokenStream::Operand, JSMSG_PAREN_AFTER_COND);
 
     /* Check for (a = b) and warn about possible (a == b) mistype. */
     if (handler.isUnparenthesizedAssignment(pn)) {
         if (!extraWarning(JSMSG_EQUAL_AS_ASSIGN))
             return null();
     }
     return pn;
 }
 
 template <class ParseHandler, typename CharT>
 bool
 GeneralParser<ParseHandler, CharT>::matchLabel(YieldHandling yieldHandling,
                                                MutableHandle<PropertyName*> label)
 {
-    TokenKind tt = TOK_EOF;
+    TokenKind tt = TokenKind::TOK_EOF;
     if (!tokenStream.peekTokenSameLine(&tt, TokenStream::Operand))
         return false;
 
     if (TokenKindIsPossibleIdentifier(tt)) {
         tokenStream.consumeKnownToken(tt, TokenStream::Operand);
 
         label.set(labelIdentifier(yieldHandling));
         if (!label)
@@ -4431,17 +4438,17 @@ GeneralParser<ParseHandler, CharT>::Poss
     transferErrorTo(ErrorKind::Expression, other);
 }
 
 template <class ParseHandler, typename CharT>
 typename ParseHandler::Node
 GeneralParser<ParseHandler, CharT>::bindingInitializer(Node lhs, DeclarationKind kind,
                                                        YieldHandling yieldHandling)
 {
-    MOZ_ASSERT(anyChars.isCurrentTokenType(TOK_ASSIGN));
+    MOZ_ASSERT(anyChars.isCurrentTokenType(TokenKind::TOK_ASSIGN));
 
     if (kind == DeclarationKind::FormalParameter)
         pc->functionBox()->hasParameterExprs = true;
 
     Node rhs = assignExpr(InAllowed, yieldHandling, TripledotProhibited);
     if (!rhs)
         return null();
 
@@ -4474,58 +4481,58 @@ GeneralParser<ParseHandler, CharT>::bind
 }
 
 template <class ParseHandler, typename CharT>
 typename ParseHandler::Node
 GeneralParser<ParseHandler, CharT>::bindingIdentifierOrPattern(DeclarationKind kind,
                                                                YieldHandling yieldHandling,
                                                                TokenKind tt)
 {
-    if (tt == TOK_LB)
+    if (tt == TokenKind::TOK_LB)
         return arrayBindingPattern(kind, yieldHandling);
 
-    if (tt == TOK_LC)
+    if (tt == TokenKind::TOK_LC)
         return objectBindingPattern(kind, yieldHandling);
 
     if (!TokenKindIsPossibleIdentifierName(tt)) {
         error(JSMSG_NO_VARIABLE_NAME);
         return null();
     }
 
     return bindingIdentifier(kind, yieldHandling);
 }
 
 template <class ParseHandler, typename CharT>
 typename ParseHandler::Node
 GeneralParser<ParseHandler, CharT>::objectBindingPattern(DeclarationKind kind,
                                                          YieldHandling yieldHandling)
 {
-    MOZ_ASSERT(anyChars.isCurrentTokenType(TOK_LC));
+    MOZ_ASSERT(anyChars.isCurrentTokenType(TokenKind::TOK_LC));
 
     if (!CheckRecursionLimit(context))
         return null();
 
     uint32_t begin = pos().begin;
     Node literal = handler.newObjectLiteral(begin);
     if (!literal)
         return null();
 
     Maybe<DeclarationKind> declKind = Some(kind);
     RootedAtom propAtom(context);
     for (;;) {
         TokenKind tt;
         if (!tokenStream.peekToken(&tt))
             return null();
-        if (tt == TOK_RC) {
+        if (tt == TokenKind::TOK_RC) {
             anyChars.addModifierException(TokenStream::OperandIsNone);
             break;
         }
 
-        if (tt == TOK_TRIPLEDOT) {
-            tokenStream.consumeKnownToken(TOK_TRIPLEDOT);
+        if (tt == TokenKind::TOK_TRIPLEDOT) {
+            tokenStream.consumeKnownToken(TokenKind::TOK_TRIPLEDOT);
             uint32_t begin = pos().begin;
 
             TokenKind tt;
             if (!tokenStream.getToken(&tt))
                 return null();
 
             if (!TokenKindIsPossibleIdentifierName(tt)) {
                 error(JSMSG_NO_VARIABLE_NAME);
@@ -4552,17 +4559,17 @@ GeneralParser<ParseHandler, CharT>::obje
                 if (!tokenStream.getToken(&tt, TokenStream::Operand))
                     return null();
 
                 Node binding = bindingIdentifierOrPattern(kind, yieldHandling, tt);
                 if (!binding)
                     return null();
 
                 bool hasInitializer;
-                if (!tokenStream.matchToken(&hasInitializer, TOK_ASSIGN, TokenStream::Operand))
+                if (!tokenStream.matchToken(&hasInitializer, TokenKind::TOK_ASSIGN, TokenStream::Operand))
                     return null();
 
                 Node bindingExpr = hasInitializer
                                    ? bindingInitializer(binding, kind, yieldHandling)
                                    : binding;
                 if (!bindingExpr)
                     return null();
 
@@ -4583,55 +4590,55 @@ GeneralParser<ParseHandler, CharT>::obje
                 // Handle e.g., |var {x=1, y=2} = o| as destructuring
                 // shorthand with default values.
                 MOZ_ASSERT(TokenKindIsPossibleIdentifierName(tt));
 
                 Node binding = bindingIdentifier(kind, yieldHandling);
                 if (!binding)
                     return null();
 
-                tokenStream.consumeKnownToken(TOK_ASSIGN);
+                tokenStream.consumeKnownToken(TokenKind::TOK_ASSIGN);
 
                 Node bindingExpr = bindingInitializer(binding, kind, yieldHandling);
                 if (!bindingExpr)
                     return null();
 
                 if (!handler.addPropertyDefinition(literal, propName, bindingExpr))
                     return null();
             } else {
                 errorAt(namePos.begin, JSMSG_NO_VARIABLE_NAME);
                 return null();
             }
         }
 
         bool matched;
-        if (!tokenStream.matchToken(&matched, TOK_COMMA, TokenStream::Operand))
+        if (!tokenStream.matchToken(&matched, TokenKind::TOK_COMMA, TokenStream::Operand))
             return null();
         if (!matched)
             break;
-        if (tt == TOK_TRIPLEDOT) {
+        if (tt == TokenKind::TOK_TRIPLEDOT) {
             error(JSMSG_REST_WITH_COMMA);
             return null();
         }
     }
 
-    MUST_MATCH_TOKEN_MOD_WITH_REPORT(TOK_RC, TokenStream::Operand,
+    MUST_MATCH_TOKEN_MOD_WITH_REPORT(TokenKind::TOK_RC, TokenStream::Operand,
                                      reportMissingClosing(JSMSG_CURLY_AFTER_LIST,
                                                           JSMSG_CURLY_OPENED, begin));
 
     handler.setEndPosition(literal, pos().end);
     return literal;
 }
 
 template <class ParseHandler, typename CharT>
 typename ParseHandler::Node
 GeneralParser<ParseHandler, CharT>::arrayBindingPattern(DeclarationKind kind,
                                                         YieldHandling yieldHandling)
 {
-    MOZ_ASSERT(anyChars.isCurrentTokenType(TOK_LB));
+    MOZ_ASSERT(anyChars.isCurrentTokenType(TokenKind::TOK_LB));
 
     if (!CheckRecursionLimit(context))
         return null();
 
     uint32_t begin = pos().begin;
     Node literal = handler.newArrayLiteral(begin);
     if (!literal)
         return null();
@@ -4642,26 +4649,26 @@ GeneralParser<ParseHandler, CharT>::arra
              error(JSMSG_ARRAY_INIT_TOO_BIG);
              return null();
          }
 
          TokenKind tt;
          if (!tokenStream.getToken(&tt))
              return null();
 
-         if (tt == TOK_RB) {
+         if (tt == TokenKind::TOK_RB) {
              anyChars.ungetToken();
              anyChars.addModifierException(TokenStream::OperandIsNone);
              break;
          }
 
-         if (tt == TOK_COMMA) {
+         if (tt == TokenKind::TOK_COMMA) {
              if (!handler.addElision(literal, pos()))
                  return null();
-         } else if (tt == TOK_TRIPLEDOT) {
+         } else if (tt == TokenKind::TOK_TRIPLEDOT) {
              uint32_t begin = pos().begin;
 
              TokenKind tt;
              if (!tokenStream.getToken(&tt))
                  return null();
 
              Node inner = bindingIdentifierOrPattern(kind, yieldHandling, tt);
              if (!inner)
@@ -4670,61 +4677,61 @@ GeneralParser<ParseHandler, CharT>::arra
              if (!handler.addSpreadElement(literal, begin, inner))
                  return null();
          } else {
              Node binding = bindingIdentifierOrPattern(kind, yieldHandling, tt);
              if (!binding)
                  return null();
 
              bool hasInitializer;
-             if (!tokenStream.matchToken(&hasInitializer, TOK_ASSIGN, TokenStream::Operand))
+             if (!tokenStream.matchToken(&hasInitializer, TokenKind::TOK_ASSIGN, TokenStream::Operand))
                  return null();
 
              Node element = hasInitializer
                             ? bindingInitializer(binding, kind, yieldHandling)
                             : binding;
              if (!element)
                  return null();
 
              handler.addArrayElement(literal, element);
          }
 
-         if (tt != TOK_COMMA) {
-             // If we didn't already match TOK_COMMA in above case.
+         if (tt != TokenKind::TOK_COMMA) {
+             // If we didn't already match TokenKind::TOK_COMMA in above case.
              bool matched;
-             if (!tokenStream.matchToken(&matched, TOK_COMMA, TokenStream::Operand))
+             if (!tokenStream.matchToken(&matched, TokenKind::TOK_COMMA, TokenStream::Operand))
                  return null();
              if (!matched)
                  break;
 
-             if (tt == TOK_TRIPLEDOT) {
+             if (tt == TokenKind::TOK_TRIPLEDOT) {
                  error(JSMSG_REST_WITH_COMMA);
                  return null();
              }
          }
      }
 
-     MUST_MATCH_TOKEN_MOD_WITH_REPORT(TOK_RB, TokenStream::Operand,
+     MUST_MATCH_TOKEN_MOD_WITH_REPORT(TokenKind::TOK_RB, TokenStream::Operand,
                                       reportMissingClosing(JSMSG_BRACKET_AFTER_LIST,
                                                            JSMSG_BRACKET_OPENED, begin));
 
     handler.setEndPosition(literal, pos().end);
     return literal;
 }
 
 template <class ParseHandler, typename CharT>
 typename ParseHandler::Node
 GeneralParser<ParseHandler, CharT>::destructuringDeclaration(DeclarationKind kind,
                                                              YieldHandling yieldHandling,
                                                              TokenKind tt)
 {
     MOZ_ASSERT(anyChars.isCurrentTokenType(tt));
-    MOZ_ASSERT(tt == TOK_LB || tt == TOK_LC);
-
-    return tt == TOK_LB
+    MOZ_ASSERT(tt == TokenKind::TOK_LB || tt == TokenKind::TOK_LC);
+
+    return tt == TokenKind::TOK_LB
            ? arrayBindingPattern(kind, yieldHandling)
            : objectBindingPattern(kind, yieldHandling);
 }
 
 template <class ParseHandler, typename CharT>
 typename ParseHandler::Node
 GeneralParser<ParseHandler, CharT>::destructuringDeclarationWithoutYieldOrAwait(DeclarationKind kind,
                                                                                 YieldHandling yieldHandling,
@@ -4746,29 +4753,29 @@ GeneralParser<ParseHandler, CharT>::dest
     return res;
 }
 
 template <class ParseHandler, typename CharT>
 typename ParseHandler::Node
 GeneralParser<ParseHandler, CharT>::blockStatement(YieldHandling yieldHandling,
                                                    unsigned errorNumber)
 {
-    MOZ_ASSERT(anyChars.isCurrentTokenType(TOK_LC));
+    MOZ_ASSERT(anyChars.isCurrentTokenType(TokenKind::TOK_LC));
     uint32_t openedPos = pos().begin;
 
     ParseContext::Statement stmt(pc, StatementKind::Block);
     ParseContext::Scope scope(this);
     if (!scope.init(pc))
         return null();
 
     Node list = statementList(yieldHandling);
     if (!list)
         return null();
 
-    MUST_MATCH_TOKEN_MOD_WITH_REPORT(TOK_RC, TokenStream::Operand,
+    MUST_MATCH_TOKEN_MOD_WITH_REPORT(TokenKind::TOK_RC, TokenStream::Operand,
                                      reportMissingClosing(errorNumber, JSMSG_CURLY_OPENED,
                                                           openedPos));
 
     return finishLexicalScope(scope, list);
 }
 
 template <class ParseHandler, typename CharT>
 typename ParseHandler::Node
@@ -4785,18 +4792,18 @@ GeneralParser<ParseHandler, CharT>::expr
 template <class ParseHandler, typename CharT>
 typename ParseHandler::Node
 GeneralParser<ParseHandler, CharT>::declarationPattern(DeclarationKind declKind, TokenKind tt,
                                                        bool initialDeclaration,
                                                        YieldHandling yieldHandling,
                                                        ParseNodeKind* forHeadKind,
                                                        Node* forInOrOfExpression)
 {
-    MOZ_ASSERT(anyChars.isCurrentTokenType(TOK_LB) ||
-               anyChars.isCurrentTokenType(TOK_LC));
+    MOZ_ASSERT(anyChars.isCurrentTokenType(TokenKind::TOK_LB) ||
+               anyChars.isCurrentTokenType(TokenKind::TOK_LC));
 
     Node pattern = destructuringDeclaration(declKind, yieldHandling, tt);
     if (!pattern)
         return null();
 
     if (initialDeclaration && forHeadKind) {
         bool isForIn, isForOf;
         if (!matchInOrOf(&isForIn, &isForOf))
@@ -4818,17 +4825,17 @@ GeneralParser<ParseHandler, CharT>::decl
             *forInOrOfExpression = expressionAfterForInOrOf(*forHeadKind, yieldHandling);
             if (!*forInOrOfExpression)
                 return null();
 
             return pattern;
         }
     }
 
-    MUST_MATCH_TOKEN_MOD(TOK_ASSIGN, TokenStream::Operand, JSMSG_BAD_DESTRUCT_DECL);
+    MUST_MATCH_TOKEN_MOD(TokenKind::TOK_ASSIGN, TokenStream::Operand, JSMSG_BAD_DESTRUCT_DECL);
 
     Node init = assignExpr(forHeadKind ? InProhibited : InAllowed,
                            yieldHandling, TripledotProhibited);
     if (!init)
         return null();
 
     handler.checkAndSetIsDirectRHSAnonFunction(init);
 
@@ -4839,17 +4846,17 @@ template <class ParseHandler, typename C
 bool
 GeneralParser<ParseHandler, CharT>::initializerInNameDeclaration(Node binding,
                                                                  DeclarationKind declKind,
                                                                  bool initialDeclaration,
                                                                  YieldHandling yieldHandling,
                                                                  ParseNodeKind* forHeadKind,
                                                                  Node* forInOrOfExpression)
 {
-    MOZ_ASSERT(anyChars.isCurrentTokenType(TOK_ASSIGN));
+    MOZ_ASSERT(anyChars.isCurrentTokenType(TokenKind::TOK_ASSIGN));
 
     uint32_t initializerOffset;
     if (!tokenStream.peekOffset(&initializerOffset, TokenStream::Operand))
         return false;
 
     Node initializer = assignExpr(forHeadKind ? InProhibited : InAllowed,
                                   yieldHandling, TripledotProhibited);
     if (!initializer)
@@ -4923,17 +4930,17 @@ GeneralParser<ParseHandler, CharT>::decl
     // The '=' context after a variable name in a declaration is an opportunity
     // for ASI, and thus for the next token to start an ExpressionStatement:
     //
     //  var foo   // VariableDeclaration
     //  /bar/g;   // ExpressionStatement
     //
     // Therefore get the token here as Operand.
     bool matched;
-    if (!tokenStream.matchToken(&matched, TOK_ASSIGN, TokenStream::Operand))
+    if (!tokenStream.matchToken(&matched, TokenKind::TOK_ASSIGN, TokenStream::Operand))
         return null();
 
     if (matched) {
         if (!initializerInNameDeclaration(binding, declKind, initialDeclaration,
                                           yieldHandling, forHeadKind, forInOrOfExpression))
         {
             return null();
         }
@@ -5013,34 +5020,34 @@ GeneralParser<ParseHandler, CharT>::decl
     do {
         MOZ_ASSERT_IF(!initialDeclaration && forHeadKind,
                       *forHeadKind == ParseNodeKind::ForHead);
 
         TokenKind tt;
         if (!tokenStream.getToken(&tt))
             return null();
 
-        Node binding = (tt == TOK_LB || tt == TOK_LC)
+        Node binding = (tt == TokenKind::TOK_LB || tt == TokenKind::TOK_LC)
                        ? declarationPattern(declKind, tt, initialDeclaration, yieldHandling,
                                             forHeadKind, forInOrOfExpression)
                        : declarationName(declKind, tt, initialDeclaration, yieldHandling,
                                          forHeadKind, forInOrOfExpression);
         if (!binding)
             return null();
 
         handler.addList(decl, binding);
 
         // If we have a for-in/of loop, the above call matches the entirety
         // of the loop head (up to the closing parenthesis).
         if (forHeadKind && *forHeadKind != ParseNodeKind::ForHead)
             break;
 
         initialDeclaration = false;
 
-        if (!tokenStream.matchToken(&moreDeclarations, TOK_COMMA, TokenStream::Operand))
+        if (!tokenStream.matchToken(&moreDeclarations, TokenKind::TOK_COMMA, TokenStream::Operand))
             return null();
     } while (moreDeclarations);
 
     return decl;
 }
 
 template <class ParseHandler, typename CharT>
 typename ParseHandler::Node
@@ -5069,37 +5076,37 @@ GeneralParser<ParseHandler, CharT>::lexi
 
     return decl;
 }
 
 template <typename CharT>
 bool
 Parser<FullParseHandler, CharT>::namedImportsOrNamespaceImport(TokenKind tt, Node importSpecSet)
 {
-    if (tt == TOK_LC) {
+    if (tt == TokenKind::TOK_LC) {
         while (true) {
             // Handle the forms |import {} from 'a'| and
             // |import { ..., } from 'a'| (where ... is non empty), by
             // escaping the loop early if the next token is }.
             if (!tokenStream.getToken(&tt))
                 return false;
 
-            if (tt == TOK_RC)
+            if (tt == TokenKind::TOK_RC)
                 break;
 
             if (!TokenKindIsPossibleIdentifierName(tt)) {
                 error(JSMSG_NO_IMPORT_NAME);
                 return false;
             }
 
             Rooted<PropertyName*> importName(context, anyChars.currentName());
             TokenPos importNamePos = pos();
 
             bool matched;
-            if (!tokenStream.matchToken(&matched, TOK_AS))
+            if (!tokenStream.matchToken(&matched, TokenKind::TOK_AS))
                 return null();
 
             if (matched) {
                 TokenKind afterAs;
                 if (!tokenStream.getToken(&afterAs))
                     return false;
 
                 if (!TokenKindIsPossibleIdentifierName(afterAs)) {
@@ -5136,28 +5143,28 @@ Parser<FullParseHandler, CharT>::namedIm
                 return false;
 
             handler.addList(importSpecSet, importSpec);
 
             TokenKind next;
             if (!tokenStream.getToken(&next))
                 return false;
 
-            if (next == TOK_RC)
+            if (next == TokenKind::TOK_RC)
                 break;
 
-            if (next != TOK_COMMA) {
+            if (next != TokenKind::TOK_COMMA) {
                 error(JSMSG_RC_AFTER_IMPORT_SPEC_LIST);
                 return false;
             }
         }
     } else {
-        MOZ_ASSERT(tt == TOK_MUL);
-
-        MUST_MATCH_TOKEN(TOK_AS, JSMSG_AS_AFTER_IMPORT_STAR);
+        MOZ_ASSERT(tt == TokenKind::TOK_MUL);
+
+        MUST_MATCH_TOKEN(TokenKind::TOK_AS, JSMSG_AS_AFTER_IMPORT_STAR);
 
         MUST_MATCH_TOKEN_FUNC(TokenKindIsPossibleIdentifierName, JSMSG_NO_BINDING_NAME);
 
         Node importName = newName(context->names().star);
         if (!importName)
             return false;
 
         // Namespace imports are are not indirect bindings but lexical
@@ -5186,38 +5193,38 @@ Parser<FullParseHandler, CharT>::namedIm
 
     return true;
 }
 
 template<typename CharT>
 ParseNode*
 Parser<FullParseHandler, CharT>::importDeclaration()
 {
-    MOZ_ASSERT(anyChars.isCurrentTokenType(TOK_IMPORT));
+    MOZ_ASSERT(anyChars.isCurrentTokenType(TokenKind::TOK_IMPORT));
 
     if (!pc->atModuleLevel()) {
         error(JSMSG_IMPORT_DECL_AT_TOP_LEVEL);
         return null();
     }
 
     uint32_t begin = pos().begin;
     TokenKind tt;
     if (!tokenStream.getToken(&tt))
         return null();
 
     Node importSpecSet = handler.newList(ParseNodeKind::ImportSpecList, pos());
     if (!importSpecSet)
         return null();
 
-    if (tt == TOK_STRING) {
+    if (tt == TokenKind::TOK_STRING) {
         // Handle the form |import 'a'| by leaving the list empty. This is
         // equivalent to |import {} from 'a'|.
         importSpecSet->pn_pos.end = importSpecSet->pn_pos.begin;
     } else {
-        if (tt == TOK_LC || tt == TOK_MUL) {
+        if (tt == TokenKind::TOK_LC || tt == TokenKind::TOK_MUL) {
             if (!namedImportsOrNamespaceImport(tt, importSpecSet))
                 return null();
         } else if (TokenKindIsPossibleIdentifierName(tt)) {
             // Handle the form |import a from 'b'|, by adding a single import
             // specifier to the list, with 'default' as the import name and
             // 'a' as the binding name. This is equivalent to
             // |import { default as a } from 'b'|.
             Node importName = newName(context->names().default_);
@@ -5239,37 +5246,37 @@ Parser<FullParseHandler, CharT>::importD
             if (!importSpec)
                 return null();
 
             handler.addList(importSpecSet, importSpec);
 
             if (!tokenStream.peekToken(&tt))
                 return null();
 
-            if (tt == TOK_COMMA) {
+            if (tt == TokenKind::TOK_COMMA) {
                 tokenStream.consumeKnownToken(tt);
                 if (!tokenStream.getToken(&tt))
                     return null();
 
-                if (tt != TOK_LC && tt != TOK_MUL) {
+                if (tt != TokenKind::TOK_LC && tt != TokenKind::TOK_MUL) {
                     error(JSMSG_NAMED_IMPORTS_OR_NAMESPACE_IMPORT);
                     return null();
                 }
 
                 if (!namedImportsOrNamespaceImport(tt, importSpecSet))
                     return null();
             }
         } else {
             error(JSMSG_DECLARATION_AFTER_IMPORT);
             return null();
         }
 
-        MUST_MATCH_TOKEN(TOK_FROM, JSMSG_FROM_AFTER_IMPORT_CLAUSE);
-
-        MUST_MATCH_TOKEN(TOK_STRING, JSMSG_MODULE_SPEC_AFTER_FROM);
+        MUST_MATCH_TOKEN(TokenKind::TOK_FROM, JSMSG_FROM_AFTER_IMPORT_CLAUSE);
+
+        MUST_MATCH_TOKEN(TokenKind::TOK_STRING, JSMSG_MODULE_SPEC_AFTER_FROM);
     }
 
     Node moduleSpec = stringLiteral();
     if (!moduleSpec)
         return null();
 
     if (!matchOrInsertSemicolon())
         return null();
@@ -5458,22 +5465,22 @@ PerHandlerParser<SyntaxParseHandler>::pr
 
 template <class ParseHandler, typename CharT>
 typename ParseHandler::Node
 GeneralParser<ParseHandler, CharT>::exportFrom(uint32_t begin, Node specList)
 {
     if (!abortIfSyntaxParser())
         return null();
 
-    MOZ_ASSERT(anyChars.isCurrentTokenType(TOK_FROM));
+    MOZ_ASSERT(anyChars.isCurrentTokenType(TokenKind::TOK_FROM));
 
     if (!abortIfSyntaxParser())
         return null();
 
-    MUST_MATCH_TOKEN(TOK_STRING, JSMSG_MODULE_SPEC_AFTER_FROM);
+    MUST_MATCH_TOKEN(TokenKind::TOK_STRING, JSMSG_MODULE_SPEC_AFTER_FROM);
 
     Node moduleSpec = stringLiteral();
     if (!moduleSpec)
         return null();
 
     if (!matchOrInsertSemicolon())
         return null();
 
@@ -5489,31 +5496,31 @@ GeneralParser<ParseHandler, CharT>::expo
 
 template <class ParseHandler, typename CharT>
 typename ParseHandler::Node
 GeneralParser<ParseHandler, CharT>::exportBatch(uint32_t begin)
 {
     if (!abortIfSyntaxParser())
         return null();
 
-    MOZ_ASSERT(anyChars.isCurrentTokenType(TOK_MUL));
+    MOZ_ASSERT(anyChars.isCurrentTokenType(TokenKind::TOK_MUL));
 
     Node kid = handler.newList(ParseNodeKind::ExportSpecList, pos());
     if (!kid)
         return null();
 
     // Handle the form |export *| by adding a special export batch
     // specifier to the list.
     Node exportSpec = handler.newExportBatchSpec(pos());
     if (!exportSpec)
         return null();
 
     handler.addList(kid, exportSpec);
 
-    MUST_MATCH_TOKEN(TOK_FROM, JSMSG_FROM_AFTER_EXPORT_STAR);
+    MUST_MATCH_TOKEN(TokenKind::TOK_FROM, JSMSG_FROM_AFTER_EXPORT_STAR);
 
     return exportFrom(begin, kid);
 }
 
 template<typename CharT>
 bool
 Parser<FullParseHandler, CharT>::checkLocalExportNames(ParseNode* node)
 {
@@ -5547,43 +5554,43 @@ GeneralParser<ParseHandler, CharT>::chec
 
 template <class ParseHandler, typename CharT>
 typename ParseHandler::Node
 GeneralParser<ParseHandler, CharT>::exportClause(uint32_t begin)
 {
     if (!abortIfSyntaxParser())
         return null();
 
-    MOZ_ASSERT(anyChars.isCurrentTokenType(TOK_LC));
+    MOZ_ASSERT(anyChars.isCurrentTokenType(TokenKind::TOK_LC));
 
     Node kid = handler.newList(ParseNodeKind::ExportSpecList, pos());
     if (!kid)
         return null();
 
     TokenKind tt;
     while (true) {
         // Handle the forms |export {}| and |export { ..., }| (where ... is non
         // empty), by escaping the loop early if the next token is }.
         if (!tokenStream.getToken(&tt))
             return null();
 
-        if (tt == TOK_RC)
+        if (tt == TokenKind::TOK_RC)
             break;
 
         if (!TokenKindIsPossibleIdentifierName(tt)) {
             error(JSMSG_NO_BINDING_NAME);
             return null();
         }
 
         Node bindingName = newName(anyChars.currentName());
         if (!bindingName)
             return null();
 
         bool foundAs;
-        if (!tokenStream.matchToken(&foundAs, TOK_AS))
+        if (!tokenStream.matchToken(&foundAs, TokenKind::TOK_AS))
             return null();
         if (foundAs)
             MUST_MATCH_TOKEN_FUNC(TokenKindIsPossibleIdentifierName, JSMSG_NO_EXPORT_NAME);
 
         Node exportName = newName(anyChars.currentName());
         if (!exportName)
             return null();
 
@@ -5595,20 +5602,20 @@ GeneralParser<ParseHandler, CharT>::expo
             return null();
 
         handler.addList(kid, exportSpec);
 
         TokenKind next;
         if (!tokenStream.getToken(&next))
             return null();
 
-        if (next == TOK_RC)
+        if (next == TokenKind::TOK_RC)
             break;
 
-        if (next != TOK_COMMA) {
+        if (next != TokenKind::TOK_COMMA) {
             error(JSMSG_RC_AFTER_EXPORT_SPEC_LIST);
             return null();
         }
     }
 
     // Careful!  If |from| follows, even on a new line, it must start a
     // FromClause:
     //
@@ -5618,17 +5625,17 @@ GeneralParser<ParseHandler, CharT>::expo
     // But if it doesn't, we might have an ASI opportunity in Operand context:
     //
     //   export { x }   // ExportDeclaration, terminated by ASI
     //   fro\u006D      // ExpressionStatement, the name "from"
     //
     // In that case let matchOrInsertSemicolon sort out ASI or any necessary
     // error.
     bool matched;
-    if (!tokenStream.matchToken(&matched, TOK_FROM, TokenStream::Operand))
+    if (!tokenStream.matchToken(&matched, TokenKind::TOK_FROM, TokenStream::Operand))
         return null();
 
     if (matched)
         return exportFrom(begin, kid);
 
     if (!matchOrInsertSemicolon())
         return null();
 
@@ -5647,17 +5654,17 @@ GeneralParser<ParseHandler, CharT>::expo
 
 template <class ParseHandler, typename CharT>
 typename ParseHandler::Node
 GeneralParser<ParseHandler, CharT>::exportVariableStatement(uint32_t begin)
 {
     if (!abortIfSyntaxParser())
         return null();
 
-    MOZ_ASSERT(anyChars.isCurrentTokenType(TOK_VAR));
+    MOZ_ASSERT(anyChars.isCurrentTokenType(TokenKind::TOK_VAR));
 
     Node kid = declarationList(YieldIsName, ParseNodeKind::Var);
     if (!kid)
         return null();
     if (!matchOrInsertSemicolon())
         return null();
     if (!checkExportedNamesForDeclaration(kid))
         return null();
@@ -5676,17 +5683,17 @@ template <class ParseHandler, typename C
 typename ParseHandler::Node
 GeneralParser<ParseHandler, CharT>::exportFunctionDeclaration(uint32_t begin,
                                                               uint32_t toStringStart,
                                                               FunctionAsyncKind asyncKind /* = SyncFunction */)
 {
     if (!abortIfSyntaxParser())
         return null();
 
-    MOZ_ASSERT(anyChars.isCurrentTokenType(TOK_FUNCTION));
+    MOZ_ASSERT(anyChars.isCurrentTokenType(TokenKind::TOK_FUNCTION));
 
     Node kid = functionStmt(toStringStart, YieldIsName, NameRequired, asyncKind);
     if (!kid)
         return null();
 
     if (!checkExportedNameForFunction(kid))
         return null();
 
@@ -5702,17 +5709,17 @@ GeneralParser<ParseHandler, CharT>::expo
 
 template <class ParseHandler, typename CharT>
 typename ParseHandler::Node
 GeneralParser<ParseHandler, CharT>::exportClassDeclaration(uint32_t begin)
 {
     if (!abortIfSyntaxParser())
         return null();
 
-    MOZ_ASSERT(anyChars.isCurrentTokenType(TOK_CLASS));
+    MOZ_ASSERT(anyChars.isCurrentTokenType(TokenKind::TOK_CLASS));
 
     Node kid = classDefinition(YieldIsName, ClassStatement, NameRequired);
     if (!kid)
         return null();
 
     if (!checkExportedNameForClass(kid))
         return null();
 
@@ -5729,18 +5736,18 @@ GeneralParser<ParseHandler, CharT>::expo
 template <class ParseHandler, typename CharT>
 typename ParseHandler::Node
 GeneralParser<ParseHandler, CharT>::exportLexicalDeclaration(uint32_t begin, DeclarationKind kind)
 {
     if (!abortIfSyntaxParser())
         return null();
 
     MOZ_ASSERT(kind == DeclarationKind::Const || kind == DeclarationKind::Let);
-    MOZ_ASSERT_IF(kind == DeclarationKind::Const, anyChars.isCurrentTokenType(TOK_CONST));
-    MOZ_ASSERT_IF(kind == DeclarationKind::Let, anyChars.isCurrentTokenType(TOK_LET));
+    MOZ_ASSERT_IF(kind == DeclarationKind::Const, anyChars.isCurrentTokenType(TokenKind::TOK_CONST));
+    MOZ_ASSERT_IF(kind == DeclarationKind::Let, anyChars.isCurrentTokenType(TokenKind::TOK_LET));
 
     Node kid = lexicalDeclaration(YieldIsName, kind);
     if (!kid)
         return null();
     if (!checkExportedNamesForDeclaration(kid))
         return null();
 
     Node node = handler.newExportDeclaration(kid, TokenPos(begin, pos().end));
@@ -5757,17 +5764,17 @@ template <class ParseHandler, typename C
 typename ParseHandler::Node
 GeneralParser<ParseHandler, CharT>::exportDefaultFunctionDeclaration(uint32_t begin,
                                                                      uint32_t toStringStart,
                                                                      FunctionAsyncKind asyncKind /* = SyncFunction */)
 {
     if (!abortIfSyntaxParser())
         return null();
 
-    MOZ_ASSERT(anyChars.isCurrentTokenType(TOK_FUNCTION));
+    MOZ_ASSERT(anyChars.isCurrentTokenType(TokenKind::TOK_FUNCTION));
 
     Node kid = functionStmt(toStringStart, YieldIsName, AllowDefaultName, asyncKind);
     if (!kid)
         return null();
 
     Node node = handler.newExportDefaultDeclaration(kid, null(), TokenPos(begin, pos().end));
     if (!node)
         return null();
@@ -5780,17 +5787,17 @@ GeneralParser<ParseHandler, CharT>::expo
 
 template <class ParseHandler, typename CharT>
 typename ParseHandler::Node
 GeneralParser<ParseHandler, CharT>::exportDefaultClassDeclaration(uint32_t begin)
 {
     if (!abortIfSyntaxParser())
         return null();
 
-    MOZ_ASSERT(anyChars.isCurrentTokenType(TOK_CLASS));
+    MOZ_ASSERT(anyChars.isCurrentTokenType(TokenKind::TOK_CLASS));
 
     Node kid = classDefinition(YieldIsName, ClassStatement, AllowDefaultName);
     if (!kid)
         return null();
 
     Node node = handler.newExportDefaultDeclaration(kid, null(), TokenPos(begin, pos().end));
     if (!node)
         return null();
@@ -5836,112 +5843,112 @@ GeneralParser<ParseHandler, CharT>::expo
 
 template <class ParseHandler, typename CharT>
 typename ParseHandler::Node
 GeneralParser<ParseHandler, CharT>::exportDefault(uint32_t begin)
 {
     if (!abortIfSyntaxParser())
         return null();
 
-    MOZ_ASSERT(anyChars.isCurrentTokenType(TOK_DEFAULT));
+    MOZ_ASSERT(anyChars.isCurrentTokenType(TokenKind::TOK_DEFAULT));
 
     TokenKind tt;
     if (!tokenStream.getToken(&tt, TokenStream::Operand))
         return null();
 
     if (!checkExportedName(context->names().default_))
         return null();
 
     switch (tt) {
-      case TOK_FUNCTION:
+      case TokenKind::TOK_FUNCTION:
         return exportDefaultFunctionDeclaration(begin, pos().begin);
 
-      case TOK_ASYNC: {
-        TokenKind nextSameLine = TOK_EOF;
+      case TokenKind::TOK_ASYNC: {
+        TokenKind nextSameLine = TokenKind::TOK_EOF;
         if (!tokenStream.peekTokenSameLine(&nextSameLine))
             return null();
 
-        if (nextSameLine == TOK_FUNCTION) {
+        if (nextSameLine == TokenKind::TOK_FUNCTION) {
             uint32_t toStringStart = pos().begin;
-            tokenStream.consumeKnownToken(TOK_FUNCTION);
+            tokenStream.consumeKnownToken(TokenKind::TOK_FUNCTION);
             return exportDefaultFunctionDeclaration(begin, toStringStart,
                                                     FunctionAsyncKind::AsyncFunction);
         }
 
         anyChars.ungetToken();
         return exportDefaultAssignExpr(begin);
       }
 
-      case TOK_CLASS:
+      case TokenKind::TOK_CLASS:
         return exportDefaultClassDeclaration(begin);
 
       default:
         anyChars.ungetToken();
         return exportDefaultAssignExpr(begin);
     }
 }
 
 template <class ParseHandler, typename CharT>
 typename ParseHandler::Node
 GeneralParser<ParseHandler, CharT>::exportDeclaration()
 {
     if (!abortIfSyntaxParser())
         return null();
 
-    MOZ_ASSERT(anyChars.isCurrentTokenType(TOK_EXPORT));
+    MOZ_ASSERT(anyChars.isCurrentTokenType(TokenKind::TOK_EXPORT));
 
     if (!pc->atModuleLevel()) {
         error(JSMSG_EXPORT_DECL_AT_TOP_LEVEL);
         return null();
     }
 
     uint32_t begin = pos().begin;
 
     TokenKind tt;
     if (!tokenStream.getToken(&tt))
         return null();
     switch (tt) {
-      case TOK_MUL:
+      case TokenKind::TOK_MUL:
         return exportBatch(begin);
 
-      case TOK_LC:
+      case TokenKind::TOK_LC:
         return exportClause(begin);
 
-      case TOK_VAR:
+      case TokenKind::TOK_VAR:
         return exportVariableStatement(begin);
 
-      case TOK_FUNCTION:
+      case TokenKind::TOK_FUNCTION:
         return exportFunctionDeclaration(begin, pos().begin);
 
-      case TOK_ASYNC: {
-        TokenKind nextSameLine = TOK_EOF;
+      case TokenKind::TOK_ASYNC: {
+        TokenKind nextSameLine = TokenKind::TOK_EOF;
         if (!tokenStream.peekTokenSameLine(&nextSameLine))
             return null();
 
-        if (nextSameLine == TOK_FUNCTION) {
+        if (nextSameLine == TokenKind::TOK_FUNCTION) {
             uint32_t toStringStart = pos().begin;
-            tokenStream.consumeKnownToken(TOK_FUNCTION);
+            tokenStream.consumeKnownToken(TokenKind::TOK_FUNCTION);
             return exportFunctionDeclaration(begin, toStringStart,
                                              FunctionAsyncKind::AsyncFunction);
         }
 
         error(JSMSG_DECLARATION_AFTER_EXPORT);
         return null();
       }
 
-      case TOK_CLASS:
+      case TokenKind::TOK_CLASS:
         return exportClassDeclaration(begin);
 
-      case TOK_CONST:
+      case TokenKind::TOK_CONST:
         return exportLexicalDeclaration(begin, DeclarationKind::Const);
 
-      case TOK_LET:
+      case TokenKind::TOK_LET:
         return exportLexicalDeclaration(begin, DeclarationKind::Let);
 
-      case TOK_DEFAULT:
+      case TokenKind::TOK_DEFAULT:
         return exportDefault(begin);
 
       default:
         error(JSMSG_DECLARATION_AFTER_EXPORT);
         return null();
     }
 }
 
@@ -5969,31 +5976,31 @@ GeneralParser<ParseHandler, CharT>::cons
         return null();
 
     // Annex B.3.4 says that unbraced FunctionDeclarations under if/else in
     // non-strict code act as if they were braced: |if (x) function f() {}|
     // parses as |if (x) { function f() {} }|.
     //
     // Careful!  FunctionDeclaration doesn't include generators or async
     // functions.
-    if (next == TOK_FUNCTION) {
+    if (next == TokenKind::TOK_FUNCTION) {
         tokenStream.consumeKnownToken(next, TokenStream::Operand);
 
         // Parser::statement would handle this, but as this function handles
         // every other error case, it seems best to handle this.
         if (pc->sc()->strict()) {
             error(JSMSG_FORBIDDEN_AS_STATEMENT, "function declarations");
             return null();
         }
 
         TokenKind maybeStar;
         if (!tokenStream.peekToken(&maybeStar))
             return null();
 
-        if (maybeStar == TOK_MUL) {
+        if (maybeStar == TokenKind::TOK_MUL) {
             error(JSMSG_FORBIDDEN_AS_STATEMENT, "generator declarations");
             return null();
         }
 
         ParseContext::Statement stmt(pc, StatementKind::Block);
         ParseContext::Scope scope(this);
         if (!scope.init(pc))
             return null();
@@ -6030,33 +6037,33 @@ GeneralParser<ParseHandler, CharT>::ifSt
         /* An IF node has three kids: condition, then, and optional else. */
         Node cond = condition(InAllowed, yieldHandling);
         if (!cond)
             return null();
 
         TokenKind tt;
         if (!tokenStream.peekToken(&tt, TokenStream::Operand))
             return null();
-        if (tt == TOK_SEMI) {
+        if (tt == TokenKind::TOK_SEMI) {
             if (!extraWarning(JSMSG_EMPTY_CONSEQUENT))
                 return null();
         }
 
         Node thenBranch = consequentOrAlternative(yieldHandling);
         if (!thenBranch)
             return null();
 
         if (!condList.append(cond) || !thenList.append(thenBranch) || !posList.append(begin))
             return null();
 
         bool matched;
-        if (!tokenStream.matchToken(&matched, TOK_ELSE, TokenStream::Operand))
+        if (!tokenStream.matchToken(&matched, TokenKind::TOK_ELSE, TokenStream::Operand))
             return null();
         if (matched) {
-            if (!tokenStream.matchToken(&matched, TOK_IF, TokenStream::Operand))
+            if (!tokenStream.matchToken(&matched, TokenKind::TOK_IF, TokenStream::Operand))
                 return null();
             if (matched)
                 continue;
             elseBranch = consequentOrAlternative(yieldHandling);
             if (!elseBranch)
                 return null();
         } else {
             elseBranch = null();
@@ -6077,29 +6084,29 @@ template <class ParseHandler, typename C
 typename ParseHandler::Node
 GeneralParser<ParseHandler, CharT>::doWhileStatement(YieldHandling yieldHandling)
 {
     uint32_t begin = pos().begin;
     ParseContext::Statement stmt(pc, StatementKind::DoLoop);
     Node body = statement(yieldHandling);
     if (!body)
         return null();
-    MUST_MATCH_TOKEN_MOD(TOK_WHILE, TokenStream::Operand, JSMSG_WHILE_AFTER_DO);
+    MUST_MATCH_TOKEN_MOD(TokenKind::TOK_WHILE, TokenStream::Operand, JSMSG_WHILE_AFTER_DO);
     Node cond = condition(InAllowed, yieldHandling);
     if (!cond)
         return null();
 
     // The semicolon after do-while is even more optional than most
     // semicolons in JS.  Web compat required this by 2004:
     //   http://bugzilla.mozilla.org/show_bug.cgi?id=238945
     // ES3 and ES5 disagreed, but ES6 conforms to Web reality:
     //   https://bugs.ecmascript.org/show_bug.cgi?id=157
     // To parse |do {} while (true) false| correctly, use Operand.
     bool ignored;
-    if (!tokenStream.matchToken(&ignored, TOK_SEMI, TokenStream::Operand))
+    if (!tokenStream.matchToken(&ignored, TokenKind::TOK_SEMI, TokenStream::Operand))
         return null();
     return handler.newDoWhileStatement(body, cond, TokenPos(begin, pos().end));
 }
 
 template <class ParseHandler, typename CharT>
 typename ParseHandler::Node
 GeneralParser<ParseHandler, CharT>::whileStatement(YieldHandling yieldHandling)
 {
@@ -6117,74 +6124,74 @@ GeneralParser<ParseHandler, CharT>::whil
 template <class ParseHandler, typename CharT>
 bool
 GeneralParser<ParseHandler, CharT>::matchInOrOf(bool* isForInp, bool* isForOfp)
 {
     TokenKind tt;
     if (!tokenStream.getToken(&tt, TokenStream::Operand))
         return false;
 
-    *isForInp = tt == TOK_IN;
-    *isForOfp = tt == TOK_OF;
+    *isForInp = tt == TokenKind::TOK_IN;
+    *isForOfp = tt == TokenKind::TOK_OF;
     if (!*isForInp && !*isForOfp)
         anyChars.ungetToken();
 
     MOZ_ASSERT_IF(*isForInp || *isForOfp, *isForInp != *isForOfp);
     return true;
 }
 
 template <class ParseHandler, typename CharT>
 bool
 GeneralParser<ParseHandler, CharT>::forHeadStart(YieldHandling yieldHandling,
                                                  ParseNodeKind* forHeadKind, Node* forInitialPart,
                                                  Maybe<ParseContext::Scope>& forLoopLexicalScope,
                                                  Node* forInOrOfExpression)
 {
-    MOZ_ASSERT(anyChars.isCurrentTokenType(TOK_LP));
+    MOZ_ASSERT(anyChars.isCurrentTokenType(TokenKind::TOK_LP));
 
     TokenKind tt;
     if (!tokenStream.peekToken(&tt, TokenStream::Operand))
         return null();
 
     // Super-duper easy case: |for (;| is a C-style for-loop with no init
     // component.
-    if (tt == TOK_SEMI) {
+    if (tt == TokenKind::TOK_SEMI) {
         *forInitialPart = null();
         *forHeadKind = ParseNodeKind::ForHead;
         return true;
     }
 
     // Parsing after |for (var| is also relatively simple (from this method's
     // point of view).  No block-related work complicates matters, so delegate
     // to Parser::declaration.
-    if (tt == TOK_VAR) {
+    if (tt == TokenKind::TOK_VAR) {
         tokenStream.consumeKnownToken(tt, TokenStream::Operand);
 
         // Pass null for block object because |var| declarations don't use one.
         *forInitialPart = declarationList(yieldHandling, ParseNodeKind::Var, forHeadKind,
                                           forInOrOfExpression);
         return *forInitialPart != null();
     }
 
     // Otherwise we have a lexical declaration or an expression.
 
     // For-in loop backwards compatibility requires that |let| starting a
     // for-loop that's not a (new to ES6) for-of loop, in non-strict mode code,
     // parse as an identifier.  (|let| in for-of is always a declaration.)
     bool parsingLexicalDeclaration = false;
     bool letIsIdentifier = false;
-    if (tt == TOK_CONST) {
+    if (tt == TokenKind::TOK_CONST) {
         parsingLexicalDeclaration = true;
         tokenStream.consumeKnownToken(tt, TokenStream::Operand);
-    } else if (tt == TOK_LET) {
+    } else if (tt == TokenKind::TOK_LET) {
         // We could have a {For,Lexical}Declaration, or we could have a
         // LeftHandSideExpression with lookahead restrictions so it's not
         // ambiguous with the former.  Check for a continuation of the former
         // to decide which we have.
-        tokenStream.consumeKnownToken(TOK_LET, TokenStream::Operand);
+        tokenStream.consumeKnownToken(TokenKind::TOK_LET, TokenStream::Operand);
 
         TokenKind next;
         if (!tokenStream.peekToken(&next))
             return false;
 
         parsingLexicalDeclaration = nextTokenContinuesLetDeclaration(next);
         if (!parsingLexicalDeclaration) {
             anyChars.ungetToken();
@@ -6198,17 +6205,17 @@ GeneralParser<ParseHandler, CharT>::forH
             return null();
 
         // Push a temporary ForLoopLexicalHead Statement that allows for
         // lexical declarations, as they are usually allowed only in braced
         // statements.
         ParseContext::Statement forHeadStmt(pc, StatementKind::ForLoopLexicalHead);
 
         *forInitialPart = declarationList(yieldHandling,
-                                          tt == TOK_CONST
+                                          tt == TokenKind::TOK_CONST
                                           ? ParseNodeKind::Const
                                           : ParseNodeKind::Let,
                                           forHeadKind, forInOrOfExpression);
         return *forInitialPart != null();
     }
 
     uint32_t exprOffset;
     if (!tokenStream.peekOffset(&exprOffset, TokenStream::Operand))
@@ -6285,38 +6292,38 @@ GeneralParser<ParseHandler, CharT>::forH
     *forInOrOfExpression = expressionAfterForInOrOf(*forHeadKind, yieldHandling);
     return *forInOrOfExpression != null();
 }
 
 template <class ParseHandler, typename CharT>
 typename ParseHandler::Node
 GeneralParser<ParseHandler, CharT>::forStatement(YieldHandling yieldHandling)
 {
-    MOZ_ASSERT(anyChars.isCurrentTokenType(TOK_FOR));
+    MOZ_ASSERT(anyChars.isCurrentTokenType(TokenKind::TOK_FOR));
 
     uint32_t begin = pos().begin;
 
     ParseContext::Statement stmt(pc, StatementKind::ForLoop);
 
     IteratorKind iterKind = IteratorKind::Sync;
     unsigned iflags = 0;
 
     if (pc->isAsync()) {
         bool matched;
-        if (!tokenStream.matchToken(&matched, TOK_AWAIT))
+        if (!tokenStream.matchToken(&matched, TokenKind::TOK_AWAIT))
             return null();
 
         if (matched) {
             iflags |= JSITER_FORAWAITOF;
             iterKind = IteratorKind::Async;
         }
     }
 
-    MUST_MATCH_TOKEN_MOD_WITH_REPORT(TOK_LP, TokenStream::None,
-                                     error((token == TOK_AWAIT && !pc->isAsync())
+    MUST_MATCH_TOKEN_MOD_WITH_REPORT(TokenKind::TOK_LP, TokenStream::None,
+                                     error((token == TokenKind::TOK_AWAIT && !pc->isAsync())
                                            ? JSMSG_FOR_AWAIT_OUTSIDE_ASYNC
                                            : JSMSG_PAREN_AFTER_FOR));
 
     // ParseNodeKind::ForHead, ParseNodeKind::ForIn, or
     // ParseNodeKind::ForOf depending on the loop type.
     ParseNodeKind headKind;
 
     // |x| in either |for (x; ...; ...)| or |for (x in/of ...)|.
@@ -6364,46 +6371,46 @@ GeneralParser<ParseHandler, CharT>::forS
     }
 
     Node forHead;
     if (headKind == ParseNodeKind::ForHead) {
         Node init = startNode;
 
         // Look for an operand: |for (;| means we might have already examined
         // this semicolon with that modifier.
-        MUST_MATCH_TOKEN_MOD(TOK_SEMI, TokenStream::Operand, JSMSG_SEMI_AFTER_FOR_INIT);
+        MUST_MATCH_TOKEN_MOD(TokenKind::TOK_SEMI, TokenStream::Operand, JSMSG_SEMI_AFTER_FOR_INIT);
 
         TokenKind tt;
         if (!tokenStream.peekToken(&tt, TokenStream::Operand))
             return null();
 
         Node test;
-        if (tt == TOK_SEMI) {
+        if (tt == TokenKind::TOK_SEMI) {
             test = null();
         } else {
             test = expr(InAllowed, yieldHandling, TripledotProhibited);
             if (!test)
                 return null();
         }
 
-        MUST_MATCH_TOKEN_MOD(TOK_SEMI, TokenStream::Operand, JSMSG_SEMI_AFTER_FOR_COND);
+        MUST_MATCH_TOKEN_MOD(TokenKind::TOK_SEMI, TokenStream::Operand, JSMSG_SEMI_AFTER_FOR_COND);
 
         if (!tokenStream.peekToken(&tt, TokenStream::Operand))
             return null();
 
         Node update;
-        if (tt == TOK_RP) {
+        if (tt == TokenKind::TOK_RP) {
             update = null();
         } else {
             update = expr(InAllowed, yieldHandling, TripledotProhibited);
             if (!update)
                 return null();
         }
 
-        MUST_MATCH_TOKEN_MOD(TOK_RP, TokenStream::Operand, JSMSG_PAREN_AFTER_FOR_CTRL);
+        MUST_MATCH_TOKEN_MOD(TokenKind::TOK_RP, TokenStream::Operand, JSMSG_PAREN_AFTER_FOR_CTRL);
 
         TokenPos headPos(begin, pos().end);
         forHead = handler.newForHead(init, test, update, headPos);
         if (!forHead)
             return null();
     } else {
         MOZ_ASSERT(headKind == ParseNodeKind::ForIn || headKind == ParseNodeKind::ForOf);
 
@@ -6416,17 +6423,17 @@ GeneralParser<ParseHandler, CharT>::forS
         if (headKind == ParseNodeKind::ForIn)
             stmt.refineForKind(StatementKind::ForInLoop);
         else
             stmt.refineForKind(StatementKind::ForOfLoop);
 
         // Parser::declaration consumed everything up to the closing ')'.  That
         // token follows an {Assignment,}Expression and so must be interpreted
         // as an operand to be consistent with normal expression tokenizing.
-        MUST_MATCH_TOKEN_MOD(TOK_RP, TokenStream::Operand, JSMSG_PAREN_AFTER_FOR_CTRL);
+        MUST_MATCH_TOKEN_MOD(TokenKind::TOK_RP, TokenStream::Operand, JSMSG_PAREN_AFTER_FOR_CTRL);
 
         TokenPos headPos(begin, pos().end);
         forHead = handler.newForInOrOfHead(headKind, target, iteratedExpr, headPos);
         if (!forHead)
             return null();
     }
 
     Node body = statement(yieldHandling);
@@ -6442,81 +6449,81 @@ GeneralParser<ParseHandler, CharT>::forS
 
     return forLoop;
 }
 
 template <class ParseHandler, typename CharT>
 typename ParseHandler::Node
 GeneralParser<ParseHandler, CharT>::switchStatement(YieldHandling yieldHandling)
 {
-    MOZ_ASSERT(anyChars.isCurrentTokenType(TOK_SWITCH));
+    MOZ_ASSERT(anyChars.isCurrentTokenType(TokenKind::TOK_SWITCH));
     uint32_t begin = pos().begin;
 
-    MUST_MATCH_TOKEN(TOK_LP, JSMSG_PAREN_BEFORE_SWITCH);
+    MUST_MATCH_TOKEN(TokenKind::TOK_LP, JSMSG_PAREN_BEFORE_SWITCH);
 
     Node discriminant = exprInParens(InAllowed, yieldHandling, TripledotProhibited);
     if (!discriminant)
         return null();
 
-    MUST_MATCH_TOKEN_MOD(TOK_RP, TokenStream::Operand, JSMSG_PAREN_AFTER_SWITCH);
-    MUST_MATCH_TOKEN(TOK_LC, JSMSG_CURLY_BEFORE_SWITCH);
+    MUST_MATCH_TOKEN_MOD(TokenKind::TOK_RP, TokenStream::Operand, JSMSG_PAREN_AFTER_SWITCH);
+    MUST_MATCH_TOKEN(TokenKind::TOK_LC, JSMSG_CURLY_BEFORE_SWITCH);
 
     ParseContext::Statement stmt(pc, StatementKind::Switch);
     ParseContext::Scope scope(this);
     if (!scope.init(pc))
         return null();
 
     Node caseList = handler.newStatementList(pos());
     if (!caseList)
         return null();
 
     bool seenDefault = false;
     TokenKind tt;
     while (true) {
         if (!tokenStream.getToken(&tt, TokenStream::Operand))
             return null();
-        if (tt == TOK_RC)
+        if (tt == TokenKind::TOK_RC)
             break;
         uint32_t caseBegin = pos().begin;
 
         Node caseExpr;
         switch (tt) {
-          case TOK_DEFAULT:
+          case TokenKind::TOK_DEFAULT:
             if (seenDefault) {
                 error(JSMSG_TOO_MANY_DEFAULTS);
                 return null();
             }
             seenDefault = true;
             caseExpr = null();  // The default case has pn_left == nullptr.
             break;
 
-          case TOK_CASE:
+          case TokenKind::TOK_CASE:
             caseExpr = expr(InAllowed, yieldHandling, TripledotProhibited);
             if (!caseExpr)
                 return null();
             break;
 
           default:
             error(JSMSG_BAD_SWITCH);
             return null();
         }
 
-        MUST_MATCH_TOKEN_MOD(TOK_COLON, TokenStream::Operand, JSMSG_COLON_AFTER_CASE);
+        MUST_MATCH_TOKEN_MOD(TokenKind::TOK_COLON, TokenStream::Operand, JSMSG_COLON_AFTER_CASE);
 
         Node body = handler.newStatementList(pos());
         if (!body)
             return null();
 
         bool afterReturn = false;
         bool warnedAboutStatementsAfterReturn = false;
         uint32_t statementBegin = 0;
         while (true) {
             if (!tokenStream.peekToken(&tt, TokenStream::Operand))
                 return null();
-            if (tt == TOK_RC || tt == TOK_CASE || tt == TOK_DEFAULT)
+            if (tt == TokenKind::TOK_RC || tt == TokenKind::TOK_CASE || tt == TokenKind::TOK_DEFAULT)
                 break;
             if (afterReturn) {
                 if (!tokenStream.peekOffset(&statementBegin, TokenStream::Operand))
                     return null();
             }
             Node stmt = statementListItem(yieldHandling);
             if (!stmt)
                 return null();
@@ -6549,17 +6556,17 @@ GeneralParser<ParseHandler, CharT>::swit
 
     return handler.newSwitchStatement(begin, discriminant, caseList);
 }
 
 template <class ParseHandler, typename CharT>
 typename ParseHandler::Node
 GeneralParser<ParseHandler, CharT>::continueStatement(YieldHandling yieldHandling)
 {
-    MOZ_ASSERT(anyChars.isCurrentTokenType(TOK_CONTINUE));
+    MOZ_ASSERT(anyChars.isCurrentTokenType(TokenKind::TOK_CONTINUE));
     uint32_t begin = pos().begin;
 
     RootedPropertyName label(context);
     if (!matchLabel(yieldHandling, &label))
         return null();
 
     auto validity = pc->checkContinueStatement(label);
     if (validity.isErr()) {
@@ -6579,17 +6586,17 @@ GeneralParser<ParseHandler, CharT>::cont
 
     return handler.newContinueStatement(label, TokenPos(begin, pos().end));
 }
 
 template <class ParseHandler, typename CharT>
 typename ParseHandler::Node
 GeneralParser<ParseHandler, CharT>::breakStatement(YieldHandling yieldHandling)
 {
-    MOZ_ASSERT(anyChars.isCurrentTokenType(TOK_BREAK));
+    MOZ_ASSERT(anyChars.isCurrentTokenType(TokenKind::TOK_BREAK));
     uint32_t begin = pos().begin;
 
     RootedPropertyName label(context);
     if (!matchLabel(yieldHandling, &label))
         return null();
 
     // Labeled 'break' statements target the nearest labeled statements (could
     // be any kind) with the same label. Unlabeled 'break' statements target
@@ -6619,34 +6626,34 @@ GeneralParser<ParseHandler, CharT>::brea
 
     return handler.newBreakStatement(label, TokenPos(begin, pos().end));
 }
 
 template <class ParseHandler, typename CharT>
 typename ParseHandler::Node
 GeneralParser<ParseHandler, CharT>::returnStatement(YieldHandling yieldHandling)
 {
-    MOZ_ASSERT(anyChars.isCurrentTokenType(TOK_RETURN));
+    MOZ_ASSERT(anyChars.isCurrentTokenType(TokenKind::TOK_RETURN));
     uint32_t begin = pos().begin;
 
     MOZ_ASSERT(pc->isFunctionBox());
     pc->functionBox()->usesReturn = true;
 
     // Parse an optional operand.
     //
     // This is ugly, but we don't want to require a semicolon.
     Node exprNode;
-    TokenKind tt = TOK_EOF;
+    TokenKind tt = TokenKind::TOK_EOF;
     if (!tokenStream.peekTokenSameLine(&tt, TokenStream::Operand))
         return null();
     switch (tt) {
-      case TOK_EOL:
-      case TOK_EOF:
-      case TOK_SEMI:
-      case TOK_RC:
+      case TokenKind::TOK_EOL:
+      case TokenKind::TOK_EOF:
+      case TokenKind::TOK_SEMI:
+      case TokenKind::TOK_RC:
         exprNode = null();
         break;
       default: {
         exprNode = expr(InAllowed, yieldHandling, TripledotProhibited);
         if (!exprNode)
             return null();
       }
     }
@@ -6656,87 +6663,87 @@ GeneralParser<ParseHandler, CharT>::retu
 
     return handler.newReturnStatement(exprNode, TokenPos(begin, pos().end));
 }
 
 template <class ParseHandler, typename CharT>
 typename ParseHandler::Node
 GeneralParser<ParseHandler, CharT>::yieldExpression(InHandling inHandling)
 {
-    MOZ_ASSERT(anyChars.isCurrentTokenType(TOK_YIELD));
+    MOZ_ASSERT(anyChars.isCurrentTokenType(TokenKind::TOK_YIELD));
     uint32_t begin = pos().begin;
 
     MOZ_ASSERT(pc->isGenerator());
     MOZ_ASSERT(pc->isFunctionBox());
 
     pc->lastYieldOffset = begin;
 
     Node exprNode;
     ParseNodeKind kind = ParseNodeKind::Yield;
-    TokenKind tt = TOK_EOF;
+    TokenKind tt = TokenKind::TOK_EOF;
     if (!tokenStream.peekTokenSameLine(&tt, TokenStream::Operand))
         return null();
     switch (tt) {
-      // TOK_EOL is special; it implements the [no LineTerminator here]
+      // TokenKind::TOK_EOL is special; it implements the [no LineTerminator here]
       // quirk in the grammar.
-      case TOK_EOL:
+      case TokenKind::TOK_EOL:
       // The rest of these make up the complete set of tokens that can
       // appear after any of the places where AssignmentExpression is used
       // throughout the grammar.  Conveniently, none of them can also be the
       // start an expression.
-      case TOK_EOF:
-      case TOK_SEMI:
-      case TOK_RC:
-      case TOK_RB:
-      case TOK_RP:
-      case TOK_COLON:
-      case TOK_COMMA:
-      case TOK_IN:
+      case TokenKind::TOK_EOF:
+      case TokenKind::TOK_SEMI:
+      case TokenKind::TOK_RC:
+      case TokenKind::TOK_RB:
+      case TokenKind::TOK_RP:
+      case TokenKind::TOK_COLON:
+      case TokenKind::TOK_COMMA:
+      case TokenKind::TOK_IN:
         // No value.
         exprNode = null();
         anyChars.addModifierException(TokenStream::NoneIsOperand);
         break;
-      case TOK_MUL:
+      case TokenKind::TOK_MUL:
         kind = ParseNodeKind::YieldStar;
-        tokenStream.consumeKnownToken(TOK_MUL, TokenStream::Operand);
+        tokenStream.consumeKnownToken(TokenKind::TOK_MUL, TokenStream::Operand);
         MOZ_FALLTHROUGH;
       default:
         exprNode = assignExpr(inHandling, YieldIsKeyword, TripledotProhibited);
         if (!exprNode)
             return null();
     }
     if (kind == ParseNodeKind::YieldStar)
         return handler.newYieldStarExpression(begin, exprNode);
     return handler.newYieldExpression(begin, exprNode);
 }
 
 template <class ParseHandler, typename CharT>
 typename ParseHandler::Node
 GeneralParser<ParseHandler, CharT>::withStatement(YieldHandling yieldHandling)
 {
-    MOZ_ASSERT(anyChars.isCurrentTokenType(TOK_WITH));
+    MOZ_ASSERT(anyChars.isCurrentTokenType(TokenKind::TOK_WITH));
     uint32_t begin = pos().begin;
 
     // Usually we want the constructs forbidden in strict mode code to be a
     // subset of those that ContextOptions::extraWarnings() warns about, and we
     // use strictModeError directly.  But while 'with' is forbidden in strict
     // mode code, it doesn't even merit a warning in non-strict code.  See
     // https://bugzilla.mozilla.org/show_bug.cgi?id=514576#c1.
     if (pc->sc()->strict()) {
         if (!strictModeError(JSMSG_STRICT_CODE_WITH))
             return null();
     }
 
-    MUST_MATCH_TOKEN(TOK_LP, JSMSG_PAREN_BEFORE_WITH);
+    MUST_MATCH_TOKEN(TokenKind::TOK_LP, JSMSG_PAREN_BEFORE_WITH);
 
     Node objectExpr = exprInParens(InAllowed, yieldHandling, TripledotProhibited);
     if (!objectExpr)
         return null();
 
-    MUST_MATCH_TOKEN_MOD(TOK_RP, TokenStream::Operand, JSMSG_PAREN_AFTER_WITH);
+    MUST_MATCH_TOKEN_MOD(TokenKind::TOK_RP, TokenStream::Operand, JSMSG_PAREN_AFTER_WITH);
 
     Node innerBlock;
     {
         ParseContext::Statement stmt(pc, StatementKind::With);
         innerBlock = statement(yieldHandling);
         if (!innerBlock)
             return null();
     }
@@ -6749,24 +6756,24 @@ GeneralParser<ParseHandler, CharT>::with
 template <class ParseHandler, typename CharT>
 typename ParseHandler::Node
 GeneralParser<ParseHandler, CharT>::labeledItem(YieldHandling yieldHandling)
 {
     TokenKind tt;
     if (!tokenStream.getToken(&tt, TokenStream::Operand))
         return null();
 
-    if (tt == TOK_FUNCTION) {
+    if (tt == TokenKind::TOK_FUNCTION) {
         TokenKind next;
         if (!tokenStream.peekToken(&next))
             return null();
 
         // GeneratorDeclaration is only matched by HoistableDeclaration in
         // StatementListItem, so generators can't be inside labels.
-        if (next == TOK_MUL) {
+        if (next == TokenKind::TOK_MUL) {
             error(JSMSG_GENERATOR_LABEL);
             return null();
         }
 
         // Per 13.13.1 it's a syntax error if LabelledItem: FunctionDeclaration
         // is ever matched.  Per Annex B.3.2 that modifies this text, this
         // applies only to strict mode code.
         if (pc->sc()->strict()) {
@@ -6795,43 +6802,43 @@ GeneralParser<ParseHandler, CharT>::labe
 
     uint32_t begin = pos().begin;
 
     if (pc->template findInnermostStatement<ParseContext::LabelStatement>(hasSameLabel)) {
         errorAt(begin, JSMSG_DUPLICATE_LABEL);
         return null();
     }
 
-    tokenStream.consumeKnownToken(TOK_COLON);
+    tokenStream.consumeKnownToken(TokenKind::TOK_COLON);
 
     /* Push a label struct and parse the statement. */
     ParseContext::LabelStatement stmt(pc, label);
     Node pn = labeledItem(yieldHandling);
     if (!pn)
         return null();
 
     return handler.newLabeledStatement(label, pn, begin);
 }
 
 template <class ParseHandler, typename CharT>
 typename ParseHandler::Node
 GeneralParser<ParseHandler, CharT>::throwStatement(YieldHandling yieldHandling)
 {
-    MOZ_ASSERT(anyChars.isCurrentTokenType(TOK_THROW));
+    MOZ_ASSERT(anyChars.isCurrentTokenType(TokenKind::TOK_THROW));
     uint32_t begin = pos().begin;
 
     /* ECMA-262 Edition 3 says 'throw [no LineTerminator here] Expr'. */
-    TokenKind tt = TOK_EOF;
+    TokenKind tt = TokenKind::TOK_EOF;
     if (!tokenStream.peekTokenSameLine(&tt, TokenStream::Operand))
         return null();
-    if (tt == TOK_EOF || tt == TOK_SEMI || tt == TOK_RC) {
+    if (tt == TokenKind::TOK_EOF || tt == TokenKind::TOK_SEMI || tt == TokenKind::TOK_RC) {
         error(JSMSG_MISSING_EXPR_AFTER_THROW);
         return null();
     }
-    if (tt == TOK_EOL) {
+    if (tt == TokenKind::TOK_EOL) {
         error(JSMSG_LINE_BREAK_AFTER_THROW);
         return null();
     }
 
     Node throwExpr = expr(InAllowed, yieldHandling, TripledotProhibited);
     if (!throwExpr)
         return null();
 
@@ -6840,95 +6847,95 @@ GeneralParser<ParseHandler, CharT>::thro
 
     return handler.newThrowStatement(throwExpr, TokenPos(begin, pos().end));
 }
 
 template <class ParseHandler, typename CharT>
 typename ParseHandler::Node
 GeneralParser<ParseHandler, CharT>::tryStatement(YieldHandling yieldHandling)
 {
-    MOZ_ASSERT(anyChars.isCurrentTokenType(TOK_TRY));
+    MOZ_ASSERT(anyChars.isCurrentTokenType(TokenKind::TOK_TRY));
     uint32_t begin = pos().begin;
 
     /*
      * try nodes are ternary.
      * kid1 is the try statement
      * kid2 is the catch node list or null
      * kid3 is the finally statement
      *
      * catch nodes are binary.
      * left is the catch-name/pattern or null
      * right is the catch block
      *
      * catch lvalue nodes are either:
      *   a single identifier
-     *   TOK_RB or TOK_RC for a destructuring left-hand side
+     *   TokenKind::TOK_RB or TokenKind::TOK_RC for a destructuring left-hand side
      *
-     * finally nodes are TOK_LC statement lists.
+     * finally nodes are TokenKind::TOK_LC statement lists.
      */
 
     Node innerBlock;
     {
-        MUST_MATCH_TOKEN(TOK_LC, JSMSG_CURLY_BEFORE_TRY);
+        MUST_MATCH_TOKEN(TokenKind::TOK_LC, JSMSG_CURLY_BEFORE_TRY);
 
         uint32_t openedPos = pos().begin;
 
         ParseContext::Statement stmt(pc, StatementKind::Try);
         ParseContext::Scope scope(this);
         if (!scope.init(pc))
             return null();
 
         innerBlock = statementList(yieldHandling);
         if (!innerBlock)
             return null();
 
         innerBlock = finishLexicalScope(scope, innerBlock);
         if (!innerBlock)
             return null();
 
-        MUST_MATCH_TOKEN_MOD_WITH_REPORT(TOK_RC, TokenStream::Operand,
+        MUST_MATCH_TOKEN_MOD_WITH_REPORT(TokenKind::TOK_RC, TokenStream::Operand,
                                          reportMissingClosing(JSMSG_CURLY_AFTER_TRY,
                                                               JSMSG_CURLY_OPENED, openedPos));
     }
 
     Node catchScope = null();
     TokenKind tt;
     if (!tokenStream.getToken(&tt))
         return null();
-    if (tt == TOK_CATCH) {
+    if (tt == TokenKind::TOK_CATCH) {
         /*
          * Create a lexical scope node around the whole catch clause,
          * including the head.
          */
         ParseContext::Statement stmt(pc, StatementKind::Catch);
         ParseContext::Scope scope(this);
         if (!scope.init(pc))
             return null();
 
         /*
          * Legal catch forms are:
          *   catch (lhs) {
          *   catch {
          * where lhs is a name or a destructuring left-hand side.
          */
         bool omittedBinding;
-        if (!tokenStream.matchToken(&omittedBinding, TOK_LC))
+        if (!tokenStream.matchToken(&omittedBinding, TokenKind::TOK_LC))
             return null();
 
         Node catchName;
         if (omittedBinding) {
             catchName = null();
         } else {
-            MUST_MATCH_TOKEN(TOK_LP, JSMSG_PAREN_BEFORE_CATCH);
+            MUST_MATCH_TOKEN(TokenKind::TOK_LP, JSMSG_PAREN_BEFORE_CATCH);
 
             if (!tokenStream.getToken(&tt))
                 return null();
             switch (tt) {
-              case TOK_LB:
-              case TOK_LC:
+              case TokenKind::TOK_LB:
+              case TokenKind::TOK_LC:
                 catchName = destructuringDeclaration(DeclarationKind::CatchParameter,
                                                      yieldHandling, tt);
                 if (!catchName)
                     return null();
                 break;
 
               default: {
                 if (!TokenKindIsPossibleIdentifierName(tt)) {
@@ -6939,19 +6946,19 @@ GeneralParser<ParseHandler, CharT>::tryS
                 catchName = bindingIdentifier(DeclarationKind::SimpleCatchParameter,
                                               yieldHandling);
                 if (!catchName)
                     return null();
                 break;
               }
             }
 
-            MUST_MATCH_TOKEN_MOD(TOK_RP, TokenStream::Operand, JSMSG_PAREN_AFTER_CATCH);
-
-            MUST_MATCH_TOKEN(TOK_LC, JSMSG_CURLY_BEFORE_CATCH);
+            MUST_MATCH_TOKEN_MOD(TokenKind::TOK_RP, TokenStream::Operand, JSMSG_PAREN_AFTER_CATCH);
+
+            MUST_MATCH_TOKEN(TokenKind::TOK_LC, JSMSG_CURLY_BEFORE_CATCH);
         }
 
         Node catchBody = catchBlockStatement(yieldHandling, scope);
         if (!catchBody)
             return null();
 
         catchScope = finishLexicalScope(scope, catchBody);
         if (!catchScope)
@@ -6962,35 +6969,35 @@ GeneralParser<ParseHandler, CharT>::tryS
         handler.setEndPosition(catchScope, pos().end);
 
         if (!tokenStream.getToken(&tt, TokenStream::Operand))
             return null();
     }
 
     Node finallyBlock = null();
 
-    if (tt == TOK_FINALLY) {
-        MUST_MATCH_TOKEN(TOK_LC, JSMSG_CURLY_BEFORE_FINALLY);
+    if (tt == TokenKind::TOK_FINALLY) {
+        MUST_MATCH_TOKEN(TokenKind::TOK_LC, JSMSG_CURLY_BEFORE_FINALLY);
 
         uint32_t openedPos = pos().begin;
 
         ParseContext::Statement stmt(pc, StatementKind::Finally);
         ParseContext::Scope scope(this);
         if (!scope.init(pc))
             return null();
 
         finallyBlock = statementList(yieldHandling);
         if (!finallyBlock)
             return null();
 
         finallyBlock = finishLexicalScope(scope, finallyBlock);
         if (!finallyBlock)
             return null();
 
-        MUST_MATCH_TOKEN_MOD_WITH_REPORT(TOK_RC, TokenStream::Operand,
+        MUST_MATCH_TOKEN_MOD_WITH_REPORT(TokenKind::TOK_RC, TokenStream::Operand,
                                          reportMissingClosing(JSMSG_CURLY_AFTER_FINALLY,
                                                               JSMSG_CURLY_OPENED, openedPos));
     } else {
         anyChars.ungetToken();
     }
     if (!catchScope && !finallyBlock) {
         error(JSMSG_CATCH_OR_FINALLY);
         return null();
@@ -7020,17 +7027,17 @@ GeneralParser<ParseHandler, CharT>::catc
     // block, so declare the name in the inner scope.
     if (!scope.addCatchParameters(pc, catchParamScope))
         return null();
 
     Node list = statementList(yieldHandling);
     if (!list)
         return null();
 
-    MUST_MATCH_TOKEN_MOD_WITH_REPORT(TOK_RC, TokenStream::Operand,
+    MUST_MATCH_TOKEN_MOD_WITH_REPORT(TokenKind::TOK_RC, TokenStream::Operand,
                                      reportMissingClosing(JSMSG_CURLY_AFTER_CATCH,
                                                           JSMSG_CURLY_OPENED, openedPos));
 
     // The catch parameter names are not bound in the body scope, so remove
     // them before generating bindings.
     scope.removeCatchParameters(pc, catchParamScope);
     return finishLexicalScope(scope, list);
 }
@@ -7075,17 +7082,17 @@ ToAccessorType(PropertyType propType)
 }
 
 template <class ParseHandler, typename CharT>
 typename ParseHandler::Node
 GeneralParser<ParseHandler, CharT>::classDefinition(YieldHandling yieldHandling,
                                                     ClassContext classContext,
                                                     DefaultHandling defaultHandling)
 {
-    MOZ_ASSERT(anyChars.isCurrentTokenType(TOK_CLASS));
+    MOZ_ASSERT(anyChars.isCurrentTokenType(TokenKind::TOK_CLASS));
 
     uint32_t classStartOffset = pos().begin;
     bool savedStrictness = setLocalStrictMode(true);
 
     TokenKind tt;
     if (!tokenStream.getToken(&tt))
         return null();
 
@@ -7127,55 +7134,55 @@ GeneralParser<ParseHandler, CharT>::clas
 
     // Because the binding definitions keep track of their blockId, we need to
     // create at least the inner binding later. Keep track of the name's position
     // in order to provide it for the nodes created later.
     TokenPos namePos = pos();
 
     Node classHeritage = null();
     bool hasHeritage;
-    if (!tokenStream.matchToken(&hasHeritage, TOK_EXTENDS))
+    if (!tokenStream.matchToken(&hasHeritage, TokenKind::TOK_EXTENDS))
         return null();
     if (hasHeritage) {
         if (!tokenStream.getToken(&tt))
             return null();
         classHeritage = memberExpr(yieldHandling, TripledotProhibited,
                                    ExpressionClosure::Forbidden, tt);
         if (!classHeritage)
             return null();
     }
 
-    MUST_MATCH_TOKEN(TOK_LC, JSMSG_CURLY_BEFORE_CLASS);
+    MUST_MATCH_TOKEN(TokenKind::TOK_LC, JSMSG_CURLY_BEFORE_CLASS);
 
     Node classMethods = handler.newClassMethodList(pos().begin);
     if (!classMethods)
         return null();
 
     Maybe<DeclarationKind> declKind = Nothing();
     for (;;) {
         TokenKind tt;
         if (!tokenStream.getToken(&tt))
             return null();
-        if (tt == TOK_RC)
+        if (tt == TokenKind::TOK_RC)
             break;
 
-        if (tt == TOK_SEMI)
+        if (tt == TokenKind::TOK_SEMI)
             continue;
 
         bool isStatic = false;
-        if (tt == TOK_STATIC) {
+        if (tt == TokenKind::TOK_STATIC) {
             if (!tokenStream.peekToken(&tt))
                 return null();
-            if (tt == TOK_RC) {
+            if (tt == TokenKind::TOK_RC) {
                 tokenStream.consumeKnownToken(tt);
                 error(JSMSG_UNEXPECTED_TOKEN, "property name", TokenKindToDesc(tt));
                 return null();
             }
 
-            if (tt != TOK_LP)
+            if (tt != TokenKind::TOK_LP)
                 isStatic = true;
             else
                 anyChars.ungetToken();
         } else {
             anyChars.ungetToken();
         }
 
         uint32_t nameOffset;
@@ -7216,28 +7223,28 @@ GeneralParser<ParseHandler, CharT>::clas
             errorAt(nameOffset, JSMSG_BAD_METHOD_DEF);
             return null();
         }
 
         RootedAtom funName(context);
         switch (propType) {
           case PropertyType::GetterNoExpressionClosure:
           case PropertyType::SetterNoExpressionClosure:
-            if (!anyChars.isCurrentTokenType(TOK_RB)) {
+            if (!anyChars.isCurrentTokenType(TokenKind::TOK_RB)) {
                 funName = prefixAccessorName(propType, propAtom);
                 if (!funName)
                     return null();
             }
             break;
           case PropertyType::Constructor:
           case PropertyType::DerivedConstructor:
             funName = name;
             break;
           default:
-            if (!anyChars.isCurrentTokenType(TOK_RB))
+            if (!anyChars.isCurrentTokenType(TokenKind::TOK_RB))
                 funName = propAtom;
         }
 
         // Calling toString on constructors need to return the source text for
         // the entire class. The end offset is unknown at this point in
         // parsing and will be amended when class parsing finishes below.
         Node fn = methodDefinition(isConstructor ? classStartOffset : nameOffset,
                                    propType, funName);
@@ -7301,23 +7308,23 @@ GeneralParser<ParseHandler, CharT>::clas
 
     return handler.newClass(nameNode, classHeritage, methodsOrBlock,
                             TokenPos(classStartOffset, classEndOffset));
 }
 
 bool
 ParserBase::nextTokenContinuesLetDeclaration(TokenKind next)
 {
-    MOZ_ASSERT(anyChars.isCurrentTokenType(TOK_LET));
+    MOZ_ASSERT(anyChars.isCurrentTokenType(TokenKind::TOK_LET));
     MOZ_ASSERT(anyChars.nextToken().type == next);
 
     TokenStreamShared::verifyConsistentModifier(TokenStreamShared::None, anyChars.nextToken());
 
     // Destructuring continues a let declaration.
-    if (next == TOK_LB || next == TOK_LC)
+    if (next == TokenKind::TOK_LB || next == TokenKind::TOK_LC)
         return true;
 
     // A "let" edge case deserves special comment.  Consider this:
     //
     //   let     // not an ASI opportunity
     //   let;
     //
     // Static semantics in §13.3.1.1 turn a LexicalDeclaration that binds
@@ -7352,211 +7359,211 @@ GeneralParser<ParseHandler, CharT>::stat
         return null();
 
     TokenKind tt;
     if (!tokenStream.getToken(&tt, TokenStream::Operand))
         return null();
 
     switch (tt) {
       // BlockStatement[?Yield, ?Return]
-      case TOK_LC:
+      case TokenKind::TOK_LC:
         return blockStatement(yieldHandling);
 
       // VariableStatement[?Yield]
-      case TOK_VAR:
+      case TokenKind::TOK_VAR:
         return variableStatement(yieldHandling);
 
       // EmptyStatement
-      case TOK_SEMI:
+      case TokenKind::TOK_SEMI:
         return handler.newEmptyStatement(pos());
 
       // ExpressionStatement[?Yield].
 
-      case TOK_YIELD: {
+      case TokenKind::TOK_YIELD: {
         // Don't use a ternary operator here due to obscure linker issues
         // around using static consts in the arms of a ternary.
         Modifier modifier;
         if (yieldExpressionsSupported())
             modifier = TokenStream::Operand;
         else
             modifier = TokenStream::None;
 
         TokenKind next;
         if (!tokenStream.peekToken(&next, modifier))
             return null();
 
-        if (next == TOK_COLON)
+        if (next == TokenKind::TOK_COLON)
             return labeledStatement(yieldHandling);
 
         return expressionStatement(yieldHandling);
       }
 
       default: {
         // Avoid getting next token with None.
-        if (tt == TOK_AWAIT && pc->isAsync())
+        if (tt == TokenKind::TOK_AWAIT && pc->isAsync())
             return expressionStatement(yieldHandling);
 
         if (!TokenKindIsPossibleIdentifier(tt))
             return expressionStatement(yieldHandling);
 
         TokenKind next;
         if (!tokenStream.peekToken(&next))
             return null();
 
         // |let| here can only be an Identifier, not a declaration.  Give nicer
         // errors for declaration-looking typos.
-        if (tt == TOK_LET) {
+        if (tt == TokenKind::TOK_LET) {
             bool forbiddenLetDeclaration = false;
 
-            if (next == TOK_LB) {
+            if (next == TokenKind::TOK_LB) {
                 // Enforce ExpressionStatement's 'let [' lookahead restriction.
                 forbiddenLetDeclaration = true;
-            } else if (next == TOK_LC || TokenKindIsPossibleIdentifier(next)) {
+            } else if (next == TokenKind::TOK_LC || TokenKindIsPossibleIdentifier(next)) {
                 // 'let {' and 'let foo' aren't completely forbidden, if ASI
                 // causes 'let' to be the entire Statement.  But if they're
                 // same-line, we can aggressively give a better error message.
                 //
-                // Note that this ignores 'yield' as TOK_YIELD: we'll handle it
+                // Note that this ignores 'yield' as TokenKind::TOK_YIELD: we'll handle it
                 // correctly but with a worse error message.
                 TokenKind nextSameLine;
                 if (!tokenStream.peekTokenSameLine(&nextSameLine))
                     return null();
 
                 MOZ_ASSERT(TokenKindIsPossibleIdentifier(nextSameLine) ||
-                           nextSameLine == TOK_LC ||
-                           nextSameLine == TOK_EOL);
-
-                forbiddenLetDeclaration = nextSameLine != TOK_EOL;
+                           nextSameLine == TokenKind::TOK_LC ||
+                           nextSameLine == TokenKind::TOK_EOL);
+
+                forbiddenLetDeclaration = nextSameLine != TokenKind::TOK_EOL;
             }
 
             if (forbiddenLetDeclaration) {
                 error(JSMSG_FORBIDDEN_AS_STATEMENT, "lexical declarations");
                 return null();
             }
-        } else if (tt == TOK_ASYNC) {
+        } else if (tt == TokenKind::TOK_ASYNC) {
             // Peek only on the same line: ExpressionStatement's lookahead
             // restriction is phrased as
             //
             //   [lookahead ∉ { {, function, async [no LineTerminator here] function, class, let [ }]
             //
             // meaning that code like this is valid:
             //
             //   if (true)
             //     async       // ASI opportunity
             //   function clownshoes() {}
             TokenKind maybeFunction;
             if (!tokenStream.peekTokenSameLine(&maybeFunction))
                 return null();
 
-            if (maybeFunction == TOK_FUNCTION) {
+            if (maybeFunction == TokenKind::TOK_FUNCTION) {
                 error(JSMSG_FORBIDDEN_AS_STATEMENT, "async function declarations");
                 return null();
             }
 
             // Otherwise this |async| begins an ExpressionStatement or is a
             // label name.
         }
 
         // NOTE: It's unfortunately allowed to have a label named 'let' in
         //       non-strict code.  💯
-        if (next == TOK_COLON)
+        if (next == TokenKind::TOK_COLON)
             return labeledStatement(yieldHandling);
 
         return expressionStatement(yieldHandling);
       }
 
-      case TOK_NEW:
+      case TokenKind::TOK_NEW:
         return expressionStatement(yieldHandling, PredictInvoked);
 
       // IfStatement[?Yield, ?Return]
-      case TOK_IF:
+      case TokenKind::TOK_IF:
         return ifStatement(yieldHandling);
 
       // BreakableStatement[?Yield, ?Return]
       //
       // BreakableStatement[Yield, Return]:
       //   IterationStatement[?Yield, ?Return]
       //   SwitchStatement[?Yield, ?Return]
-      case TOK_DO:
+      case TokenKind::TOK_DO:
         return doWhileStatement(yieldHandling);
 
-      case TOK_WHILE:
+      case TokenKind::TOK_WHILE:
         return whileStatement(yieldHandling);
 
-      case TOK_FOR:
+      case TokenKind::TOK_FOR:
         return forStatement(yieldHandling);
 
-      case TOK_SWITCH:
+      case TokenKind::TOK_SWITCH:
         return switchStatement(yieldHandling);
 
       // ContinueStatement[?Yield]
-      case TOK_CONTINUE:
+      case TokenKind::TOK_CONTINUE:
         return continueStatement(yieldHandling);
 
       // BreakStatement[?Yield]
-      case TOK_BREAK:
+      case TokenKind::TOK_BREAK:
         return breakStatement(yieldHandling);
 
       // [+Return] ReturnStatement[?Yield]
-      case TOK_RETURN:
+      case TokenKind::TOK_RETURN:
         // The Return parameter is only used here, and the effect is easily
         // detected this way, so don't bother passing around an extra parameter
         // everywhere.
         if (!pc->isFunctionBox()) {
             error(JSMSG_BAD_RETURN_OR_YIELD, js_return_str);
             return null();
         }
         return returnStatement(yieldHandling);
 
       // WithStatement[?Yield, ?Return]
-      case TOK_WITH:
+      case TokenKind::TOK_WITH:
         return withStatement(yieldHandling);
 
       // LabelledStatement[?Yield, ?Return]
-      // This is really handled by default and TOK_YIELD cases above.
+      // This is really handled by default and TokenKind::TOK_YIELD cases above.
 
       // ThrowStatement[?Yield]
-      case TOK_THROW:
+      case TokenKind::TOK_THROW:
         return throwStatement(yieldHandling);
 
       // TryStatement[?Yield, ?Return]
-      case TOK_TRY:
+      case TokenKind::TOK_TRY:
         return tryStatement(yieldHandling);
 
       // DebuggerStatement
-      case TOK_DEBUGGER:
+      case TokenKind::TOK_DEBUGGER:
         return debuggerStatement();
 
       // |function| is forbidden by lookahead restriction (unless as child
       // statement of |if| or |else|, but Parser::consequentOrAlternative
       // handles that).
-      case TOK_FUNCTION:
+      case TokenKind::TOK_FUNCTION:
         error(JSMSG_FORBIDDEN_AS_STATEMENT, "function declarations");
         return null();
 
       // |class| is also forbidden by lookahead restriction.
-      case TOK_CLASS:
+      case TokenKind::TOK_CLASS:
         error(JSMSG_FORBIDDEN_AS_STATEMENT, "classes");
         return null();
 
       // ImportDeclaration (only inside modules)
-      case TOK_IMPORT:
+      case TokenKind::TOK_IMPORT:
         return importDeclaration();
 
       // ExportDeclaration (only inside modules)
-      case TOK_EXPORT:
+      case TokenKind::TOK_EXPORT:
         return exportDeclaration();
 
       // Miscellaneous error cases arguably better caught here than elsewhere.
 
-      case TOK_CATCH:
+      case TokenKind::TOK_CATCH:
         error(JSMSG_CATCH_WITHOUT_TRY);
         return null();
 
-      case TOK_FINALLY:
+      case TokenKind::TOK_FINALLY:
         error(JSMSG_FINALLY_WITHOUT_TRY);
         return null();
 
       // NOTE: default case handled in the ExpressionStatement section.
     }
 }
 
 template <class ParseHandler, typename CharT>
@@ -7570,186 +7577,186 @@ GeneralParser<ParseHandler, CharT>::stat
         return null();
 
     TokenKind tt;
     if (!tokenStream.getToken(&tt, TokenStream::Operand))
         return null();
 
     switch (tt) {
       // BlockStatement[?Yield, ?Return]
-      case TOK_LC:
+      case TokenKind::TOK_LC:
         return blockStatement(yieldHandling);
 
       // VariableStatement[?Yield]
-      case TOK_VAR:
+      case TokenKind::TOK_VAR:
         return variableStatement(yieldHandling);
 
       // EmptyStatement
-      case TOK_SEMI:
+      case TokenKind::TOK_SEMI:
         return handler.newEmptyStatement(pos());
 
       // ExpressionStatement[?Yield].
       //
       // These should probably be handled by a single ExpressionStatement
       // function in a default, not split up this way.
-      case TOK_STRING:
+      case TokenKind::TOK_STRING:
         if (!canHaveDirectives && anyChars.currentToken().atom() == context->names().useAsm) {
             if (!abortIfSyntaxParser())
                 return null();
             if (!warning(JSMSG_USE_ASM_DIRECTIVE_FAIL))
                 return null();
         }
         return expressionStatement(yieldHandling);
 
-      case TOK_YIELD: {
+      case TokenKind::TOK_YIELD: {
         // Don't use a ternary operator here due to obscure linker issues
         // around using static consts in the arms of a ternary.
         Modifier modifier;
         if (yieldExpressionsSupported())
             modifier = TokenStream::Operand;
         else
             modifier = TokenStream::None;
 
         TokenKind next;
         if (!tokenStream.peekToken(&next, modifier))
             return null();
 
-        if (next == TOK_COLON)
+        if (next == TokenKind::TOK_COLON)
             return labeledStatement(yieldHandling);
 
         return expressionStatement(yieldHandling);
       }
 
       default: {
         // Avoid getting next token with None.
-        if (tt == TOK_AWAIT && pc->isAsync())
+        if (tt == TokenKind::TOK_AWAIT && pc->isAsync())
             return expressionStatement(yieldHandling);
 
         if (!TokenKindIsPossibleIdentifier(tt))
             return expressionStatement(yieldHandling);
 
         TokenKind next;
         if (!tokenStream.peekToken(&next))
             return null();
 
-        if (tt == TOK_LET && nextTokenContinuesLetDeclaration(next))
+        if (tt == TokenKind::TOK_LET && nextTokenContinuesLetDeclaration(next))
             return lexicalDeclaration(yieldHandling, DeclarationKind::Let);
 
-        if (tt == TOK_ASYNC) {
-            TokenKind nextSameLine = TOK_EOF;
+        if (tt == TokenKind::TOK_ASYNC) {
+            TokenKind nextSameLine = TokenKind::TOK_EOF;
             if (!tokenStream.peekTokenSameLine(&nextSameLine))
                 return null();
-            if (nextSameLine == TOK_FUNCTION) {
+            if (nextSameLine == TokenKind::TOK_FUNCTION) {
                 uint32_t toStringStart = pos().begin;
-                tokenStream.consumeKnownToken(TOK_FUNCTION);
+                tokenStream.consumeKnownToken(TokenKind::TOK_FUNCTION);
                 return functionStmt(toStringStart, yieldHandling, NameRequired,
                                     FunctionAsyncKind::AsyncFunction);
             }
         }
 
-        if (next == TOK_COLON)
+        if (next == TokenKind::TOK_COLON)
             return labeledStatement(yieldHandling);
 
         return expressionStatement(yieldHandling);
       }
 
-      case TOK_NEW:
+      case TokenKind::TOK_NEW:
         return expressionStatement(yieldHandling, PredictInvoked);
 
       // IfStatement[?Yield, ?Return]
-      case TOK_IF:
+      case TokenKind::TOK_IF:
         return ifStatement(yieldHandling);
 
       // BreakableStatement[?Yield, ?Return]
       //
       // BreakableStatement[Yield, Return]:
       //   IterationStatement[?Yield, ?Return]
       //   SwitchStatement[?Yield, ?Return]
-      case TOK_DO:
+      case TokenKind::TOK_DO:
         return doWhileStatement(yieldHandling);
 
-      case TOK_WHILE:
+      case TokenKind::TOK_WHILE:
         return whileStatement(yieldHandling);
 
-      case TOK_FOR:
+      case TokenKind::TOK_FOR:
         return forStatement(yieldHandling);
 
-      case TOK_SWITCH:
+      case TokenKind::TOK_SWITCH:
         return switchStatement(yieldHandling);
 
       // ContinueStatement[?Yield]
-      case TOK_CONTINUE:
+      case TokenKind::TOK_CONTINUE:
         return continueStatement(yieldHandling);
 
       // BreakStatement[?Yield]
-      case TOK_BREAK:
+      case TokenKind::TOK_BREAK:
         return breakStatement(yieldHandling);
 
       // [+Return] ReturnStatement[?Yield]
-      case TOK_RETURN:
+      case TokenKind::TOK_RETURN:
         // The Return parameter is only used here, and the effect is easily
         // detected this way, so don't bother passing around an extra parameter
         // everywhere.
         if (!pc->isFunctionBox()) {
             error(JSMSG_BAD_RETURN_OR_YIELD, js_return_str);
             return null();
         }
         return returnStatement(yieldHandling);
 
       // WithStatement[?Yield, ?Return]
-      case TOK_WITH:
+      case TokenKind::TOK_WITH:
         return withStatement(yieldHandling);
 
       // LabelledStatement[?Yield, ?Return]
-      // This is really handled by default and TOK_YIELD cases above.
+      // This is really handled by default and TokenKind::TOK_YIELD cases above.
 
       // ThrowStatement[?Yield]
-      case TOK_THROW:
+      case TokenKind::TOK_THROW:
         return throwStatement(yieldHandling);
 
       // TryStatement[?Yield, ?Return]
-      case TOK_TRY:
+      case TokenKind::TOK_TRY:
         return tryStatement(yieldHandling);
 
       // DebuggerStatement
-      case TOK_DEBUGGER:
+      case TokenKind::TOK_DEBUGGER:
         return debuggerStatement();
 
       // Declaration[Yield]:
 
       //   HoistableDeclaration[?Yield, ~Default]
-      case TOK_FUNCTION:
+      case TokenKind::TOK_FUNCTION:
         return functionStmt(pos().begin, yieldHandling, NameRequired);
 
       //   ClassDeclaration[?Yield, ~Default]
-      case TOK_CLASS:
+      case TokenKind::TOK_CLASS:
         return classDefinition(yieldHandling, ClassStatement, NameRequired);
 
       //   LexicalDeclaration[In, ?Yield]
       //     LetOrConst BindingList[?In, ?Yield]
-      case TOK_CONST:
+      case TokenKind::TOK_CONST:
         // [In] is the default behavior, because for-loops specially parse
         // their heads to handle |in| in this situation.
         return lexicalDeclaration(yieldHandling, DeclarationKind::Const);
 
       // ImportDeclaration (only inside modules)
-      case TOK_IMPORT:
+      case TokenKind::TOK_IMPORT:
         return importDeclaration();
 
       // ExportDeclaration (only inside modules)
-      case TOK_EXPORT:
+      case TokenKind::TOK_EXPORT:
         return exportDeclaration();
 
       // Miscellaneous error cases arguably better caught here than elsewhere.
 
-      case TOK_CATCH:
+      case TokenKind::TOK_CATCH:
         error(JSMSG_CATCH_WITHOUT_TRY);
         return null();
 
-      case TOK_FINALLY:
+      case TokenKind::TOK_FINALLY:
         error(JSMSG_FINALLY_WITHOUT_TRY);
         return null();
 
       // NOTE: default case handled in the ExpressionStatement section.
     }
 }
 
 template <class ParseHandler, typename CharT>
@@ -7760,17 +7767,17 @@ GeneralParser<ParseHandler, CharT>::expr
                                          InvokedPrediction invoked /* = PredictUninvoked */)
 {
     Node pn = assignExpr(inHandling, yieldHandling, tripledotHandling,
                          possibleError, invoked);
     if (!pn)
         return null();
 
     bool matched;
-    if (!tokenStream.matchToken(&matched, TOK_COMMA, TokenStream::Operand))
+    if (!tokenStream.matchToken(&matched, TokenKind::TOK_COMMA, TokenStream::Operand))
         return null();
     if (!matched)
         return pn;
 
     Node seq = handler.newCommaExpressionList(pn);
     if (!seq)
         return null();
     while (true) {
@@ -7779,23 +7786,23 @@ GeneralParser<ParseHandler, CharT>::expr
         // directly under CoverParenthesizedExpressionAndArrowParameterList,
         // and the next two tokens are closing parenthesis and arrow. If all
         // are present allow the trailing comma.
         if (tripledotHandling == TripledotAllowed) {
             TokenKind tt;
             if (!tokenStream.peekToken(&tt, TokenStream::Operand))
                 return null();
 
-            if (tt == TOK_RP) {
-                tokenStream.consumeKnownToken(TOK_RP, TokenStream::Operand);
+            if (tt == TokenKind::TOK_RP) {
+                tokenStream.consumeKnownToken(TokenKind::TOK_RP, TokenStream::Operand);
 
                 if (!tokenStream.peekToken(&tt))
                     return null();
-                if (tt != TOK_ARROW) {
-                    error(JSMSG_UNEXPECTED_TOKEN, "expression", TokenKindToDesc(TOK_RP));
+                if (tt != TokenKind::TOK_ARROW) {
+                    error(JSMSG_UNEXPECTED_TOKEN, "expression", TokenKindToDesc(TokenKind::TOK_RP));
                     return null();
                 }
 
                 anyChars.ungetToken();  // put back right paren
                 break;
             }
         }
 
@@ -7814,29 +7821,29 @@ GeneralParser<ParseHandler, CharT>::expr
             if (!possibleErrorInner.checkForExpressionError())
                 return null();
         } else {
             possibleErrorInner.transferErrorsTo(possibleError);
         }
 
         handler.addList(seq, pn);
 
-        if (!tokenStream.matchToken(&matched, TOK_COMMA, TokenStream::Operand))
+        if (!tokenStream.matchToken(&matched, TokenKind::TOK_COMMA, TokenStream::Operand))
             return null();
         if (!matched)
             break;
     }
     return seq;
 }
 
 static ParseNodeKind
 BinaryOpTokenKindToParseNodeKind(TokenKind tok)
 {
     MOZ_ASSERT(TokenKindIsBinaryOp(tok));
-    return ParseNodeKind(size_t(ParseNodeKind::BinOpFirst) + (tok - TOK_BINOP_FIRST));
+    return ParseNodeKind(size_t(ParseNodeKind::BinOpFirst) + (size_t(tok) - size_t(TokenKind::TOK_BINOP_FIRST)));
 }
 
 static const int PrecedenceTable[] = {
     1, /* ParseNodeKind::PipeLine */
     2, /* ParseNodeKind::Or */
     3, /* ParseNodeKind::And */
     4, /* ParseNodeKind::BitOr */
     5, /* ParseNodeKind::BitXor */
@@ -7908,29 +7915,29 @@ GeneralParser<ParseHandler, CharT>::orEx
 
         // If a binary operator follows, consume it and compute the
         // corresponding operator.
         TokenKind tok;
         if (!tokenStream.getToken(&tok))
             return null();
 
         ParseNodeKind pnk;
-        if (tok == TOK_IN ? inHandling == InAllowed : TokenKindIsBinaryOp(tok)) {
+        if (tok == TokenKind::TOK_IN ? inHandling == InAllowed : TokenKindIsBinaryOp(tok)) {
             // We're definitely not in a destructuring context, so report any
             // pending expression error now.
             if (possibleError && !possibleError->checkForExpressionError())
                 return null();
             // Report an error for unary expressions on the LHS of **.
-            if (tok == TOK_POW && handler.isUnparenthesizedUnaryExpression(pn)) {
+            if (tok == TokenKind::TOK_POW && handler.isUnparenthesizedUnaryExpression(pn)) {
                 error(JSMSG_BAD_POW_LEFTSIDE);
                 return null();
             }
             pnk = BinaryOpTokenKindToParseNodeKind(tok);
         } else {
-            tok = TOK_EOF;
+            tok = TokenKind::TOK_EOF;
             pnk = ParseNodeKind::Limit;
         }
 
         // From this point on, destructuring defaults are definitely an error.
         possibleError = nullptr;
 
         // If pnk has precedence less than or equal to another operator on the
         // stack, reduce. This combines nodes on the stack until we form the
@@ -7978,26 +7985,26 @@ GeneralParser<ParseHandler, CharT>::cond
                             expressionClosureHandling, possibleError, invoked);
     if (!condition)
         return null();
 
     if (handler.isExpressionClosure(condition))
         return condition;
 
     bool matched;
-    if (!tokenStream.matchToken(&matched, TOK_HOOK))
+    if (!tokenStream.matchToken(&matched, TokenKind::TOK_HOOK))
         return null();
     if (!matched)
         return condition;
 
     Node thenExpr = assignExpr(InAllowed, yieldHandling, TripledotProhibited);
     if (!thenExpr)
         return null();
 
-    MUST_MATCH_TOKEN_MOD(TOK_COLON, TokenStream::Operand, JSMSG_COLON_IN_COND);
+    MUST_MATCH_TOKEN_MOD(TokenKind::TOK_COLON, TokenStream::Operand, JSMSG_COLON_IN_COND);
 
     Node elseExpr = assignExpr(inHandling, yieldHandling, TripledotProhibited);
     if (!elseExpr)
         return null();
 
     return handler.newConditional(condition, thenExpr, elseExpr);
 }
 
@@ -8028,48 +8035,48 @@ GeneralParser<ParseHandler, CharT>::assi
 
     TokenPos exprPos = pos();
 
     bool endsExpr;
 
     // This only handles identifiers that *never* have special meaning anywhere
     // in the language.  Contextual keywords, reserved words in strict mode,
     // and other hard cases are handled outside this fast path.
-    if (firstToken == TOK_NAME) {
+    if (firstToken == TokenKind::TOK_NAME) {
         if (!tokenStream.nextTokenEndsExpr(&endsExpr))
             return null();
         if (endsExpr) {
             Rooted<PropertyName*> name(context, identifierReference(yieldHandling));
             if (!name)
                 return null();
 
             return identifierReference(name);
         }
     }
 
-    if (firstToken == TOK_NUMBER) {
+    if (firstToken == TokenKind::TOK_NUMBER) {
         if (!tokenStream.nextTokenEndsExpr(&endsExpr))
             return null();
         if (endsExpr)
             return newNumber(anyChars.currentToken());
     }
 
-    if (firstToken == TOK_STRING) {
+    if (firstToken == TokenKind::TOK_STRING) {
         if (!tokenStream.nextTokenEndsExpr(&endsExpr))
             return null();
         if (endsExpr)
             return stringLiteral();
     }
 
-    if (firstToken == TOK_YIELD && yieldExpressionsSupported())
+    if (firstToken == TokenKind::TOK_YIELD && yieldExpressionsSupported())
         return yieldExpression(inHandling);
 
     bool maybeAsyncArrow = false;
-    if (firstToken == TOK_ASYNC) {
-        TokenKind nextSameLine = TOK_EOF;
+    if (firstToken == TokenKind::TOK_ASYNC) {
+        TokenKind nextSameLine = TokenKind::TOK_EOF;
         if (!tokenStream.peekTokenSameLine(&nextSameLine))
             return null();
 
         if (TokenKindIsPossibleIdentifier(nextSameLine))
             maybeAsyncArrow = true;
     }
 
     anyChars.ungetToken();
@@ -8079,31 +8086,31 @@ GeneralParser<ParseHandler, CharT>::assi
     typename TokenStream::Position start(keepAtoms);
     tokenStream.tell(&start);
 
     PossibleError possibleErrorInner(*this);
     Node lhs;
     TokenKind tokenAfterLHS;
     bool isArrow;
     if (maybeAsyncArrow) {
-        tokenStream.consumeKnownToken(TOK_ASYNC, TokenStream::Operand);
+        tokenStream.consumeKnownToken(TokenKind::TOK_ASYNC, TokenStream::Operand);
 
         TokenKind tokenAfterAsync;
         if (!tokenStream.getToken(&tokenAfterAsync))
             return null();
         MOZ_ASSERT(TokenKindIsPossibleIdentifier(tokenAfterAsync));
 
         // Check yield validity here.
         RootedPropertyName name(context, bindingIdentifier(yieldHandling));
         if (!name)
             return null();
 
         if (!tokenStream.peekTokenSameLine(&tokenAfterLHS))
             return null();
-        if (tokenAfterLHS != TOK_ARROW) {
+        if (tokenAfterLHS != TokenKind::TOK_ARROW) {
             error(JSMSG_UNEXPECTED_TOKEN,
                   "'=>' on the same line after an argument list", TokenKindToDesc(tokenAfterLHS));
             return null();
         }
 
         isArrow = true;
     } else {
         lhs = condExpr(inHandling, yieldHandling, tripledotHandling, ExpressionClosure::Allowed,
@@ -8112,41 +8119,41 @@ GeneralParser<ParseHandler, CharT>::assi
             return null();
 
         // Use Operand here because the ConditionalExpression parsed above
         // could be the entirety of this AssignmentExpression, and then ASI
         // permits this token to be a regular expression.
         if (!tokenStream.peekTokenSameLine(&tokenAfterLHS, TokenStream::Operand))
             return null();
 
-        isArrow = tokenAfterLHS == TOK_ARROW;
+        isArrow = tokenAfterLHS == TokenKind::TOK_ARROW;
     }
 
     if (isArrow) {
         tokenStream.seek(start);
 
         TokenKind next;
         if (!tokenStream.getToken(&next, TokenStream::Operand))
             return null();
         uint32_t toStringStart = pos().begin;
         anyChars.ungetToken();
 
         FunctionAsyncKind asyncKind = FunctionAsyncKind::SyncFunction;
 
-        if (next == TOK_ASYNC) {
+        if (next == TokenKind::TOK_ASYNC) {
             tokenStream.consumeKnownToken(next, TokenStream::Operand);
 
-            TokenKind nextSameLine = TOK_EOF;
+            TokenKind nextSameLine = TokenKind::TOK_EOF;
             if (!tokenStream.peekTokenSameLine(&nextSameLine))
                 return null();
 
             // The AsyncArrowFunction production are
             //   async [no LineTerminator here] AsyncArrowBindingIdentifier ...
             //   async [no LineTerminator here] ArrowFormalParameters ...
-            if (TokenKindIsPossibleIdentifier(nextSameLine) || nextSameLine == TOK_LP)
+            if (TokenKindIsPossibleIdentifier(nextSameLine) || nextSameLine == TokenKind::TOK_LP)
                 asyncKind = FunctionAsyncKind::AsyncFunction;
             else
                 anyChars.ungetToken();
         }
 
         Node pn = handler.newArrowFunction(pos());
         if (!pn)
             return null();
@@ -8154,29 +8161,29 @@ GeneralParser<ParseHandler, CharT>::assi
         return functionDefinition(pn, toStringStart, inHandling, yieldHandling, nullptr, Arrow,
                                   GeneratorKind::NotGenerator, asyncKind);
     }
 
     MOZ_ALWAYS_TRUE(tokenStream.getToken(&tokenAfterLHS, TokenStream::Operand));
 
     ParseNodeKind kind;
     switch (tokenAfterLHS) {
-      case TOK_ASSIGN:       kind = ParseNodeKind::Assign;       break;
-      case TOK_ADDASSIGN:    kind = ParseNodeKind::AddAssign;    break;
-      case TOK_SUBASSIGN:    kind = ParseNodeKind::SubAssign;    break;
-      case TOK_BITORASSIGN:  kind = ParseNodeKind::BitOrAssign;  break;
-      case TOK_BITXORASSIGN: kind = ParseNodeKind::BitXorAssign; break;
-      case TOK_BITANDASSIGN: kind = ParseNodeKind::BitAndAssign; break;
-      case TOK_LSHASSIGN:    kind = ParseNodeKind::LshAssign;    break;
-      case TOK_RSHASSIGN:    kind = ParseNodeKind::RshAssign;    break;
-      case TOK_URSHASSIGN:   kind = ParseNodeKind::UrshAssign;   break;
-      case TOK_MULASSIGN:    kind = ParseNodeKind::MulAssign;    break;
-      case TOK_DIVASSIGN:    kind = ParseNodeKind::DivAssign;    break;
-      case TOK_MODASSIGN:    kind = ParseNodeKind::ModAssign;    break;
-      case TOK_POWASSIGN:    kind = ParseNodeKind::PowAssign;    break;
+      case TokenKind::TOK_ASSIGN:       kind = ParseNodeKind::Assign;       break;
+      case TokenKind::TOK_ADDASSIGN:    kind = ParseNodeKind::AddAssign;    break;
+      case TokenKind::TOK_SUBASSIGN:    kind = ParseNodeKind::SubAssign;    break;
+      case TokenKind::TOK_BITORASSIGN:  kind = ParseNodeKind::BitOrAssign;  break;
+      case TokenKind::TOK_BITXORASSIGN: kind = ParseNodeKind::BitXorAssign; break;
+      case TokenKind::TOK_BITANDASSIGN: kind = ParseNodeKind::BitAndAssign; break;
+      case TokenKind::TOK_LSHASSIGN:    kind = ParseNodeKind::LshAssign;    break;
+      case TokenKind::TOK_RSHASSIGN:    kind = ParseNodeKind::RshAssign;    break;
+      case TokenKind::TOK_URSHASSIGN:   kind = ParseNodeKind::UrshAssign;   break;
+      case TokenKind::TOK_MULASSIGN:    kind = ParseNodeKind::MulAssign;    break;
+      case TokenKind::TOK_DIVASSIGN:    kind = ParseNodeKind::DivAssign;    break;
+      case TokenKind::TOK_MODASSIGN:    kind = ParseNodeKind::ModAssign;    break;
+      case TokenKind::TOK_POWASSIGN:    kind = ParseNodeKind::PowAssign;    break;
 
       default:
         MOZ_ASSERT(!anyChars.isCurrentTokenAssignment());
         if (!possibleError) {
             if (!possibleErrorInner.checkForExpressionError())
                 return null();
         } else {
             possibleErrorInner.transferErrorsTo(possibleError);
@@ -8319,28 +8326,28 @@ GeneralParser<ParseHandler, CharT>::unar
     if (!CheckRecursionLimit(context))
         return null();
 
     TokenKind tt;
     if (!tokenStream.getToken(&tt, TokenStream::Operand))
         return null();
     uint32_t begin = pos().begin;
     switch (tt) {
-      case TOK_VOID:
+      case TokenKind::TOK_VOID:
         return unaryOpExpr(yieldHandling, ParseNodeKind::Void, begin);
-      case TOK_NOT:
+      case TokenKind::TOK_NOT:
         return unaryOpExpr(yieldHandling, ParseNodeKind::Not, begin);
-      case TOK_BITNOT:
+      case TokenKind::TOK_BITNOT:
         return unaryOpExpr(yieldHandling, ParseNodeKind::BitNot, begin);
-      case TOK_ADD:
+      case TokenKind::TOK_ADD:
         return unaryOpExpr(yieldHandling, ParseNodeKind::Pos, begin);
-      case TOK_SUB:
+      case TokenKind::TOK_SUB:
         return unaryOpExpr(yieldHandling, ParseNodeKind::Neg, begin);
 
-      case TOK_TYPEOF: {
+      case TokenKind::TOK_TYPEOF: {
         // The |typeof| operator is specially parsed to distinguish its
         // application to a name, from its application to a non-name
         // expression:
         //
         //   // Looks up the name, doesn't find it and so evaluates to
         //   // "undefined".
         //   assertEq(typeof nonExistentName, "undefined");
         //
@@ -8349,35 +8356,35 @@ GeneralParser<ParseHandler, CharT>::unar
         //   typeof (1, nonExistentName);
         Node kid = unaryExpr(yieldHandling, TripledotProhibited, ExpressionClosure::Forbidden);
         if (!kid)
             return null();
 
         return handler.newTypeof(begin, kid);
       }
 
-      case TOK_INC:
-      case TOK_DEC:
+      case TokenKind::TOK_INC:
+      case TokenKind::TOK_DEC:
       {
         TokenKind tt2;
         if (!tokenStream.getToken(&tt2, TokenStream::Operand))
             return null();
 
         uint32_t operandOffset = pos().begin;
         Node operand =
             memberExpr(yieldHandling, TripledotProhibited, ExpressionClosure::Forbidden, tt2);
         if (!operand || !checkIncDecOperand(operand, operandOffset))
             return null();
-        ParseNodeKind pnk = (tt == TOK_INC)
+        ParseNodeKind pnk = (tt == TokenKind::TOK_INC)
                             ? ParseNodeKind::PreIncrement
                             : ParseNodeKind::PreDecrement;
         return handler.newUpdate(pnk, begin, operand);
       }
 
-      case TOK_DELETE: {
+      case TokenKind::TOK_DELETE: {
         uint32_t exprOffset;
         if (!tokenStream.peekOffset(&exprOffset, TokenStream::Operand))
             return null();
 
         Node expr = unaryExpr(yieldHandling, TripledotProhibited, ExpressionClosure::Forbidden);
         if (!expr)
             return null();
 
@@ -8388,17 +8395,17 @@ GeneralParser<ParseHandler, CharT>::unar
                 return null();
 
             pc->sc()->setBindingsAccessedDynamically();
         }
 
         return handler.newDelete(begin, expr);
       }
 
-      case TOK_AWAIT: {
+      case TokenKind::TOK_AWAIT: {
         if (pc->isAsync()) {
             Node kid = unaryExpr(yieldHandling, tripledotHandling, ExpressionClosure::Forbidden,
                                  possibleError, invoked);
             if (!kid)
                 return null();
             pc->lastAwaitOffset = begin;
             return handler.newAwaitExpression(begin, kid);
         }
@@ -8414,24 +8421,24 @@ GeneralParser<ParseHandler, CharT>::unar
 
         if (handler.isExpressionClosure(expr))
             return expr;
 
         /* Don't look across a newline boundary for a postfix incop. */
         if (!tokenStream.peekTokenSameLine(&tt))
             return null();
 
-        if (tt != TOK_INC && tt != TOK_DEC)
+        if (tt != TokenKind::TOK_INC && tt != TokenKind::TOK_DEC)
             return expr;
 
         tokenStream.consumeKnownToken(tt);
         if (!checkIncDecOperand(expr, begin))
             return null();
 
-        ParseNodeKind pnk = (tt == TOK_INC)
+        ParseNodeKind pnk = (tt == TokenKind::TOK_INC)
                             ? ParseNodeKind::PostIncrement
                             : ParseNodeKind::PostDecrement;
         return handler.newUpdate(pnk, begin, expr);
       }
     }
 }
 
 
@@ -8457,27 +8464,27 @@ GeneralParser<ParseHandler, CharT>::assi
 
 template <class ParseHandler, typename CharT>
 bool
 GeneralParser<ParseHandler, CharT>::argumentList(YieldHandling yieldHandling, Node listNode,
                                                  bool* isSpread,
                                                  PossibleError* possibleError /* = nullptr */)
 {
     bool matched;
-    if (!tokenStream.matchToken(&matched, TOK_RP, TokenStream::Operand))
+    if (!tokenStream.matchToken(&matched, TokenKind::TOK_RP, TokenStream::Operand))
         return false;
     if (matched) {
         handler.setEndPosition(listNode, pos().end);
         return true;
     }
 
     while (true) {
         bool spread = false;
         uint32_t begin = 0;
-        if (!tokenStream.matchToken(&matched, TOK_TRIPLEDOT, TokenStream::Operand))
+        if (!tokenStream.matchToken(&matched, TokenKind::TOK_TRIPLEDOT, TokenStream::Operand))
             return false;
         if (matched) {
             spread = true;
             begin = pos().begin;
             *isSpread = true;
         }
 
         Node argNode = assignExpr(InAllowed, yieldHandling, TripledotProhibited, possibleError);
@@ -8487,29 +8494,29 @@ GeneralParser<ParseHandler, CharT>::argu
             argNode = handler.newSpread(begin, argNode);
             if (!argNode)
                 return false;
         }
 
         handler.addList(listNode, argNode);
 
         bool matched;
-        if (!tokenStream.matchToken(&matched, TOK_COMMA, TokenStream::Operand))
+        if (!tokenStream.matchToken(&matched, TokenKind::TOK_COMMA, TokenStream::Operand))
             return false;
         if (!matched)
             break;
 
         TokenKind tt;
         if (!tokenStream.peekToken(&tt, TokenStream::Operand))
             return null();
-        if (tt == TOK_RP)
+        if (tt == TokenKind::TOK_RP)
             break;
     }
 
-    MUST_MATCH_TOKEN_MOD(TOK_RP, TokenStream::Operand, JSMSG_PAREN_AFTER_ARGS);
+    MUST_MATCH_TOKEN_MOD(TokenKind::TOK_RP, TokenStream::Operand, JSMSG_PAREN_AFTER_ARGS);
 
     handler.setEndPosition(listNode, pos().end);
     return true;
 }
 
 bool
 ParserBase::checkAndMarkSuperScope()
 {
@@ -8532,17 +8539,17 @@ GeneralParser<ParseHandler, CharT>::memb
     MOZ_ASSERT(anyChars.isCurrentTokenType(tt));
 
     Node lhs;
 
     if (!CheckRecursionLimit(context))
         return null();
 
     /* Check for new expression first. */
-    if (tt == TOK_NEW) {
+    if (tt == TokenKind::TOK_NEW) {
         uint32_t newBegin = pos().begin;
         // Make sure this wasn't a |new.target| in disguise.
         Node newTarget;
         if (!tryNewTarget(newTarget))
             return null();
         if (newTarget) {
             lhs = newTarget;
         } else {
@@ -8555,93 +8562,93 @@ GeneralParser<ParseHandler, CharT>::memb
             if (!ctorExpr)
                 return null();
 
             lhs = handler.newNewExpression(newBegin, ctorExpr);
             if (!lhs)
                 return null();
 
             bool matched;
-            if (!tokenStream.matchToken(&matched, TOK_LP))
+            if (!tokenStream.matchToken(&matched, TokenKind::TOK_LP))
                 return null();
             if (matched) {
                 bool isSpread = false;
                 if (!argumentList(yieldHandling, lhs, &isSpread))
                     return null();
                 if (isSpread)
                     handler.setOp(lhs, JSOP_SPREADNEW);
             }
         }
-    } else if (tt == TOK_SUPER) {
+    } else if (tt == TokenKind::TOK_SUPER) {
         Node thisName = newThisName();
         if (!thisName)
             return null();
         lhs = handler.newSuperBase(thisName, pos());
         if (!lhs)
             return null();
     } else {
         lhs = primaryExpr(yieldHandling, tripledotHandling, expressionClosureHandling, tt,
                           possibleError, invoked);
         if (!lhs)
             return null();
 
         if (handler.isExpressionClosure(lhs))
             return lhs;
     }
 
-    MOZ_ASSERT_IF(handler.isSuperBase(lhs), anyChars.isCurrentTokenType(TOK_SUPER));
+    MOZ_ASSERT_IF(handler.isSuperBase(lhs), anyChars.isCurrentTokenType(TokenKind::TOK_SUPER));
 
     while (true) {
         if (!tokenStream.getToken(&tt))
             return null();
-        if (tt == TOK_EOF)
+        if (tt == TokenKind::TOK_EOF)
             break;
 
         Node nextMember;
-        if (tt == TOK_DOT) {
+        if (tt == TokenKind::TOK_DOT) {
             if (!tokenStream.getToken(&tt))
                 return null();
             if (TokenKindIsPossibleIdentifierName(tt)) {
                 PropertyName* field = anyChars.currentName();
                 if (handler.isSuperBase(lhs) && !checkAndMarkSuperScope()) {
                     error(JSMSG_BAD_SUPERPROP, "property");
                     return null();
                 }
                 nextMember = handler.newPropertyAccess(lhs, field, pos().end);
                 if (!nextMember)
                     return null();
             } else {
                 error(JSMSG_NAME_AFTER_DOT);
                 return null();
             }
-        } else if (tt == TOK_LB) {
+        } else if (tt == TokenKind::TOK_LB) {
             Node propExpr = expr(InAllowed, yieldHandling, TripledotProhibited);
             if (!propExpr)
                 return null();
 
-            MUST_MATCH_TOKEN_MOD(TOK_RB, TokenStream::Operand, JSMSG_BRACKET_IN_INDEX);
+            MUST_MATCH_TOKEN_MOD(TokenKind::TOK_RB, TokenStream::Operand, JSMSG_BRACKET_IN_INDEX);
 
             if (handler.isSuperBase(lhs) && !checkAndMarkSuperScope()) {
                 error(JSMSG_BAD_SUPERPROP, "member");
                 return null();
             }
             nextMember = handler.newPropertyByValue(lhs, propExpr, pos().end);
             if (!nextMember)
                 return null();
-        } else if ((allowCallSyntax && tt == TOK_LP) ||
-                   tt == TOK_TEMPLATE_HEAD ||
-                   tt == TOK_NO_SUBS_TEMPLATE)
+        } else if ((allowCallSyntax && tt == TokenKind::TOK_LP) ||
+                   tt == TokenKind::TOK_TEMPLATE_HEAD ||
+                   tt == TokenKind::TOK_NO_SUBS_TEMPLATE)
         {
             if (handler.isSuperBase(lhs)) {
                 if (!pc->sc()->allowSuperCall()) {
                     error(JSMSG_BAD_SUPERCALL);
                     return null();
                 }
 
-                if (tt != TOK_LP) {
+                if (tt != TokenKind::TOK_LP) {
                     error(JSMSG_BAD_SUPER);
                     return null();
                 }
 
                 nextMember = handler.newSuperCall(lhs);
                 if (!nextMember)
                     return null();
 
@@ -8664,17 +8671,17 @@ GeneralParser<ParseHandler, CharT>::memb
                     return null();
             } else {
                 if (options().selfHostingMode && handler.isPropertyAccess(lhs)) {
                     error(JSMSG_SELFHOSTED_METHOD_CALL);
                     return null();
                 }
 
                 TokenPos nextMemberPos = pos();
-                nextMember = tt == TOK_LP
+                nextMember = tt == TokenKind::TOK_LP
                              ? handler.newCall(nextMemberPos)
                              : handler.newTaggedTemplate(nextMemberPos);
                 if (!nextMember)
                     return null();
 
                 JSOp op = JSOP_CALL;
                 bool maybeAsyncArrow = false;
                 if (PropertyName* prop = handler.maybeDottedProperty(lhs)) {
@@ -8682,17 +8689,17 @@ GeneralParser<ParseHandler, CharT>::memb
                     // right syntax.
                     if (prop == context->names().apply) {
                         op = JSOP_FUNAPPLY;
                         if (pc->isFunctionBox())
                             pc->functionBox()->usesApply = true;
                     } else if (prop == context->names().call) {
                         op = JSOP_FUNCALL;
                     }
-                } else if (tt == TOK_LP) {
+                } else if (tt == TokenKind::TOK_LP) {
                     if (handler.isAsyncKeyword(lhs, context)) {
                         // |async (| can be the start of an async arrow
                         // function, so we need to defer reporting possible
                         // errors from destructuring syntax. To give better
                         // error messages, we only allow the AsyncArrowHead
                         // part of the CoverCallExpressionAndAsyncArrowHead
                         // syntax when the initial name is "async".
                         maybeAsyncArrow = true;
@@ -8714,17 +8721,17 @@ GeneralParser<ParseHandler, CharT>::memb
                         // ignore the return value.)
                         checkAndMarkSuperScope();
                     }
                 }
 
                 handler.setBeginPosition(nextMember, lhs);
                 handler.addList(nextMember, lhs);
 
-                if (tt == TOK_LP) {
+                if (tt == TokenKind::TOK_LP) {
                     bool isSpread = false;
                     PossibleError* asyncPossibleError = maybeAsyncArrow ? possibleError : nullptr;
                     if (!argumentList(yieldHandling, nextMember, &isSpread, asyncPossibleError))
                         return null();
                     if (isSpread) {
                         if (op == JSOP_EVAL)
                             op = JSOP_SPREADEVAL;
                         else if (op == JSOP_STRICTEVAL)
@@ -8770,54 +8777,54 @@ PerHandlerParser<ParseHandler>::newName(
     return handler.newName(name, pos, context);
 }
 
 template <class ParseHandler, typename CharT>
 bool
 GeneralParser<ParseHandler, CharT>::checkLabelOrIdentifierReference(PropertyName* ident,
                                                                     uint32_t offset,
                                                                     YieldHandling yieldHandling,
-                                                                    TokenKind hint /* = TOK_LIMIT */)
+                                                                    TokenKind hint /* = TokenKind::TOK_LIMIT */)
 {
     TokenKind tt;
-    if (hint == TOK_LIMIT) {
+    if (hint == TokenKind::TOK_LIMIT) {
         tt = ReservedWordTokenKind(ident);
     } else {
         MOZ_ASSERT(hint == ReservedWordTokenKind(ident), "hint doesn't match actual token kind");
         tt = hint;
     }
 
-    if (tt == TOK_NAME)
+    if (tt == TokenKind::TOK_NAME)
         return true;
     if (TokenKindIsContextualKeyword(tt)) {
-        if (tt == TOK_YIELD) {
+        if (tt == TokenKind::TOK_YIELD) {
             if (yieldHandling == YieldIsKeyword) {
                 errorAt(offset, JSMSG_RESERVED_ID, "yield");
                 return false;
             }
             if (pc->sc()->needStrictChecks()) {
                 if (!strictModeErrorAt(offset, JSMSG_RESERVED_ID, "yield"))
                     return false;
             }
             return true;
         }
-        if (tt == TOK_AWAIT) {
+        if (tt == TokenKind::TOK_AWAIT) {
             if (awaitIsKeyword()) {
                 errorAt(offset, JSMSG_RESERVED_ID, "await");
                 return false;
             }
             return true;
         }
         if (pc->sc()->needStrictChecks()) {
-            if (tt == TOK_LET) {
+            if (tt == TokenKind::TOK_LET) {
                 if (!strictModeErrorAt(offset, JSMSG_RESERVED_ID, "let"))
                     return false;
                 return true;
             }
-            if (tt == TOK_STATIC) {
+            if (tt == TokenKind::TOK_STATIC) {
                 if (!strictModeErrorAt(offset, JSMSG_RESERVED_ID, "static"))
                     return false;
                 return true;
             }
         }
         return true;
     }
     if (TokenKindIsStrictReservedWord(tt)) {
@@ -8838,17 +8845,17 @@ GeneralParser<ParseHandler, CharT>::chec
     MOZ_ASSERT_UNREACHABLE("Unexpected reserved word kind.");
     return false;
 }
 
 template <class ParseHandler, typename CharT>
 bool
 GeneralParser<ParseHandler, CharT>::checkBindingIdentifier(PropertyName* ident, uint32_t offset,
                                                            YieldHandling yieldHandling,
-                                                           TokenKind hint /* = TOK_LIMIT */)
+                                                           TokenKind hint /* = TokenKind::TOK_LIMIT */)
 {
     if (pc->sc()->needStrictChecks()) {
         if (ident == context->names().arguments) {
             if (!strictModeErrorAt(offset, JSMSG_BAD_STRICT_ASSIGN, "arguments"))
                 return false;
             return true;
         }
 
@@ -8872,30 +8879,30 @@ GeneralParser<ParseHandler, CharT>::labe
     //   Identifier whose code point sequence is the same as a ReservedWord.
     //
     // Use PropertyName* instead of TokenKind to reflect the normalization.
 
     // Unless the name contains escapes, we can reuse the current TokenKind
     // to determine if the name is a restricted identifier.
     TokenKind hint = !anyChars.currentNameHasEscapes()
                      ? anyChars.currentToken().type
-                     : TOK_LIMIT;
+                     : TokenKind::TOK_LIMIT;
     RootedPropertyName ident(context, anyChars.currentName());
     if (!checkLabelOrIdentifierReference(ident, pos().begin, yieldHandling, hint))
         return nullptr;
     return ident;
 }
 
 template <class ParseHandler, typename CharT>
 PropertyName*
 GeneralParser<ParseHandler, CharT>::bindingIdentifier(YieldHandling yieldHandling)
 {
     TokenKind hint = !anyChars.currentNameHasEscapes()
                      ? anyChars.currentToken().type
-                     : TOK_LIMIT;
+                     : TokenKind::TOK_LIMIT;
     RootedPropertyName ident(context, anyChars.currentName());
     if (!checkBindingIdentifier(ident, pos().begin, yieldHandling, hint))
         return nullptr;
     return ident;
 }
 
 template <class ParseHandler>
 typename ParseHandler::Node
@@ -9099,28 +9106,28 @@ GeneralParser<ParseHandler, CharT>::chec
     return checkDestructuringAssignmentTarget(expr, exprPos, exprPossibleError, possibleError);
 }
 
 template <class ParseHandler, typename CharT>
 typename ParseHandler::Node
 GeneralParser<ParseHandler, CharT>::arrayInitializer(YieldHandling yieldHandling,
                                                      PossibleError* possibleError)
 {
-    MOZ_ASSERT(anyChars.isCurrentTokenType(TOK_LB));
+    MOZ_ASSERT(anyChars.isCurrentTokenType(TokenKind::TOK_LB));
 
     uint32_t begin = pos().begin;
     Node literal = handler.newArrayLiteral(begin);
     if (!literal)
         return null();
 
     TokenKind tt;
     if (!tokenStream.getToken(&tt, TokenStream::Operand))
         return null();
 
-    if (tt == TOK_RB) {
+    if (tt == TokenKind::TOK_RB) {
         /*
          * Mark empty arrays as non-constant, since we cannot easily
          * determine their type.
          */
         handler.setListFlag(literal, PNX_NONCONST);
     } else {
         anyChars.ungetToken();
 
@@ -9128,28 +9135,28 @@ GeneralParser<ParseHandler, CharT>::arra
             if (index >= NativeObject::MAX_DENSE_ELEMENTS_COUNT) {
                 error(JSMSG_ARRAY_INIT_TOO_BIG);
                 return null();
             }
 
             TokenKind tt;
             if (!tokenStream.peekToken(&tt, TokenStream::Operand))
                 return null();
-            if (tt == TOK_RB)
+            if (tt == TokenKind::TOK_RB)
                 break;
 
-            if (tt == TOK_COMMA) {
-                tokenStream.consumeKnownToken(TOK_COMMA, TokenStream::Operand);
+            if (tt == TokenKind::TOK_COMMA) {
+                tokenStream.consumeKnownToken(TokenKind::TOK_COMMA, TokenStream::Operand);
                 if (!handler.addElision(literal, pos()))
                     return null();
                 continue;
             }
 
-            if (tt == TOK_TRIPLEDOT) {
-                tokenStream.consumeKnownToken(TOK_TRIPLEDOT, TokenStream::Operand);
+            if (tt == TokenKind::TOK_TRIPLEDOT) {
+                tokenStream.consumeKnownToken(TokenKind::TOK_TRIPLEDOT, TokenStream::Operand);
                 uint32_t begin = pos().begin;
 
                 TokenPos innerPos;
                 if (!tokenStream.peekTokenPos(&innerPos, TokenStream::Operand))
                     return null();
 
                 PossibleError possibleErrorInner(*this);
                 Node inner = assignExpr(InAllowed, yieldHandling, TripledotProhibited,
@@ -9180,26 +9187,26 @@ GeneralParser<ParseHandler, CharT>::arra
                     return null();
                 }
                 if (foldConstants && !FoldConstants(context, &element, this))
                     return null();
                 handler.addArrayElement(literal, element);
             }
 
             bool matched;
-            if (!tokenStream.matchToken(&matched, TOK_COMMA, TokenStream::Operand))
+            if (!tokenStream.matchToken(&matched, TokenKind::TOK_COMMA, TokenStream::Operand))
                 return null();
             if (!matched)
                 break;
 
-            if (tt == TOK_TRIPLEDOT && possibleError)
+            if (tt == TokenKind::TOK_TRIPLEDOT && possibleError)
                 possibleError->setPendingDestructuringErrorAt(pos(), JSMSG_REST_WITH_COMMA);
         }
 
-        MUST_MATCH_TOKEN_MOD_WITH_REPORT(TOK_RB, TokenStream::Operand,
+        MUST_MATCH_TOKEN_MOD_WITH_REPORT(TokenKind::TOK_RB, TokenStream::Operand,
                                          reportMissingClosing(JSMSG_BRACKET_AFTER_LIST,
                                                               JSMSG_BRACKET_OPENED, begin));
     }
 
     handler.setEndPosition(literal, pos().end);
     return literal;
 }
 
@@ -9218,22 +9225,22 @@ GeneralParser<ParseHandler, CharT>::prop
                                                  Node propList,
                                                  PropertyType* propType,
                                                  MutableHandleAtom propAtom)
 {
     TokenKind ltok;
     if (!tokenStream.getToken(&ltok))
         return null();
 
-    MOZ_ASSERT(ltok != TOK_RC, "caller should have handled TOK_RC");
+    MOZ_ASSERT(ltok != TokenKind::TOK_RC, "caller should have handled TokenKind::TOK_RC");
 
     bool isGenerator = false;
     bool isAsync = false;
 
-    if (ltok == TOK_ASYNC) {
+    if (ltok == TokenKind::TOK_ASYNC) {
         // AsyncMethod[Yield, Await]:
         //   async [no LineTerminator here] PropertyName[?Yield, ?Await] ...
         //
         //  AsyncGeneratorMethod[Yield, Await]:
         //    async [no LineTerminator here] * PropertyName[?Yield, ?Await] ...
         //
         // PropertyName:
         //   LiteralPropertyName
@@ -9241,161 +9248,161 @@ GeneralParser<ParseHandler, CharT>::prop
         //
         // LiteralPropertyName:
         //   IdentifierName
         //   StringLiteral
         //   NumericLiteral
         //
         // ComputedPropertyName[Yield, Await]:
         //   [ ...
-        TokenKind tt = TOK_EOF;
+        TokenKind tt = TokenKind::TOK_EOF;
         if (!tokenStream.peekTokenSameLine(&tt))
             return null();
-        if (tt == TOK_STRING || tt == TOK_NUMBER || tt == TOK_LB ||
-            TokenKindIsPossibleIdentifierName(tt) || tt == TOK_MUL)
+        if (tt == TokenKind::TOK_STRING || tt == TokenKind::TOK_NUMBER || tt == TokenKind::TOK_LB ||
+            TokenKindIsPossibleIdentifierName(tt) || tt == TokenKind::TOK_MUL)
         {
             isAsync = true;
             tokenStream.consumeKnownToken(tt);
             ltok = tt;
         }
     }
 
-    if (ltok == TOK_MUL) {
+    if (ltok == TokenKind::TOK_MUL) {
         isGenerator = true;
         if (!tokenStream.getToken(&ltok))
             return null();
     }
 
     propAtom.set(nullptr);
     Node propName;
     switch (ltok) {
-      case TOK_NUMBER:
+      case TokenKind::TOK_NUMBER:
         propAtom.set(DoubleToAtom(context, anyChars.currentToken().number()));
         if (!propAtom.get())
             return null();
         propName = newNumber(anyChars.currentToken());
         if (!propName)
             return null();
         break;
 
-      case TOK_STRING: {
+      case TokenKind::TOK_STRING: {
         propAtom.set(anyChars.currentToken().atom());
         uint32_t index;
         if (propAtom->isIndex(&index)) {
             propName = handler.newNumber(index, NoDecimal, pos());
             if (!propName)
                 return null();
             break;
         }
         propName = stringLiteral();
         if (!propName)
             return null();
         break;
       }
 
-      case TOK_LB:
+      case TokenKind::TOK_LB:
         propName = computedPropertyName(yieldHandling, maybeDecl, propList);
         if (!propName)
             return null();
         break;
 
       default: {
         if (!TokenKindIsPossibleIdentifierName(ltok)) {
             error(JSMSG_UNEXPECTED_TOKEN, "property name", TokenKindToDesc(ltok));
             return null();
         }
 
         propAtom.set(anyChars.currentName());
         // Do not look for accessor syntax on generator or async methods.
-        if (isGenerator || isAsync || !(ltok == TOK_GET || ltok == TOK_SET)) {
+        if (isGenerator || isAsync || !(ltok == TokenKind::TOK_GET || ltok == TokenKind::TOK_SET)) {
             propName = handler.newObjectLiteralPropertyName(propAtom, pos());
             if (!propName)
                 return null();
             break;
         }
 
-        *propType = ltok == TOK_GET ? PropertyType::Getter : PropertyType::Setter;
+        *propType = ltok == TokenKind::TOK_GET ? PropertyType::Getter : PropertyType::Setter;
 
         // We have parsed |get| or |set|. Look for an accessor property
         // name next.
         TokenKind tt;
         if (!tokenStream.peekToken(&tt))
             return null();
         if (TokenKindIsPossibleIdentifierName(tt)) {
             tokenStream.consumeKnownToken(tt);
 
             propAtom.set(anyChars.currentName());
             return handler.newObjectLiteralPropertyName(propAtom, pos());
         }
-        if (tt == TOK_STRING) {
-            tokenStream.consumeKnownToken(TOK_STRING);
+        if (tt == TokenKind::TOK_STRING) {
+            tokenStream.consumeKnownToken(TokenKind::TOK_STRING);
 
             propAtom.set(anyChars.currentToken().atom());
 
             uint32_t index;
             if (propAtom->isIndex(&index)) {
                 propAtom.set(DoubleToAtom(context, index));
                 if (!propAtom.get())
                     return null();
                 return handler.newNumber(index, NoDecimal, pos());
             }
             return stringLiteral();
         }
-        if (tt == TOK_NUMBER) {
-            tokenStream.consumeKnownToken(TOK_NUMBER);
+        if (tt == TokenKind::TOK_NUMBER) {
+            tokenStream.consumeKnownToken(TokenKind::TOK_NUMBER);
 
             propAtom.set(DoubleToAtom(context, anyChars.currentToken().number()));
             if (!propAtom.get())
                 return null();
             return newNumber(anyChars.currentToken());
         }
-        if (tt == TOK_LB) {
-            tokenStream.consumeKnownToken(TOK_LB);
+        if (tt == TokenKind::TOK_LB) {
+            tokenStream.consumeKnownToken(TokenKind::TOK_LB);
 
             return computedPropertyName(yieldHandling, maybeDecl, propList);
         }
 
         // Not an accessor property after all.
         propName = handler.newObjectLiteralPropertyName(propAtom.get(), pos());
         if (!propName)
             return null();
         break;
       }
     }
 
     TokenKind tt;
     if (!tokenStream.getToken(&tt))
         return null();
 
-    if (tt == TOK_COLON) {
+    if (tt == TokenKind::TOK_COLON) {
         if (isGenerator || isAsync) {
             error(JSMSG_BAD_PROP_ID);
             return null();
         }
         *propType = PropertyType::Normal;
         return propName;
     }
 
     if (TokenKindIsPossibleIdentifierName(ltok) &&
-        (tt == TOK_COMMA || tt == TOK_RC || tt == TOK_ASSIGN))
+        (tt == TokenKind::TOK_COMMA || tt == TokenKind::TOK_RC || tt == TokenKind::TOK_ASSIGN))
     {
         if (isGenerator || isAsync) {
             error(JSMSG_BAD_PROP_ID);
             return null();
         }
 
         anyChars.ungetToken();
         anyChars.addModifierException(TokenStream::OperandIsNone);
-        *propType = tt == TOK_ASSIGN
+        *propType = tt == TokenKind::TOK_ASSIGN
                     ? PropertyType::CoverInitializedName
                     : PropertyType::Shorthand;
         return propName;
     }
 
-    if (tt == TOK_LP) {
+    if (tt == TokenKind::TOK_LP) {
         anyChars.ungetToken();
 
         if (isGenerator && isAsync)
             *propType = PropertyType::AsyncGeneratorMethod;
         else if (isGenerator)
             *propType = PropertyType::GeneratorMethod;
         else if (isAsync)
             *propType = PropertyType::AsyncMethod;
@@ -9409,63 +9416,63 @@ GeneralParser<ParseHandler, CharT>::prop
 }
 
 template <class ParseHandler, typename CharT>
 typename ParseHandler::Node
 GeneralParser<ParseHandler, CharT>::computedPropertyName(YieldHandling yieldHandling,
                                                          const Maybe<DeclarationKind>& maybeDecl,
                                                          Node literal)
 {
-    MOZ_ASSERT(anyChars.isCurrentTokenType(TOK_LB));
+    MOZ_ASSERT(anyChars.isCurrentTokenType(TokenKind::TOK_LB));
 
     uint32_t begin = pos().begin;
 
     if (maybeDecl) {
         if (*maybeDecl == DeclarationKind::FormalParameter)
             pc->functionBox()->hasParameterExprs = true;
     } else {
         handler.setListFlag(literal, PNX_NONCONST);
     }
 
     Node assignNode = assignExpr(InAllowed, yieldHandling, TripledotProhibited);
     if (!assignNode)
         return null();
 
-    MUST_MATCH_TOKEN_MOD(TOK_RB, TokenStream::Operand, JSMSG_COMP_PROP_UNTERM_EXPR);
+    MUST_MATCH_TOKEN_MOD(TokenKind::TOK_RB, TokenStream::Operand, JSMSG_COMP_PROP_UNTERM_EXPR);
     return handler.newComputedName(assignNode, begin, pos().end);
 }
 
 template <class ParseHandler, typename CharT>
 typename ParseHandler::Node
 GeneralParser<ParseHandler, CharT>::objectLiteral(YieldHandling yieldHandling,
                                                   PossibleError* possibleError)
 {
-    MOZ_ASSERT(anyChars.isCurrentTokenType(TOK_LC));
+    MOZ_ASSERT(anyChars.isCurrentTokenType(TokenKind::TOK_LC));
 
     uint32_t openedPos = pos().begin;
 
     Node literal = handler.newObjectLiteral(pos().begin);
     if (!literal)
         return null();
 
     bool seenPrototypeMutation = false;
     bool seenCoverInitializedName = false;
     Maybe<DeclarationKind> declKind = Nothing();
     RootedAtom propAtom(context);
     for (;;) {
         TokenKind tt;
         if (!tokenStream.peekToken(&tt))
             return null();
-        if (tt == TOK_RC) {
+        if (tt == TokenKind::TOK_RC) {
             anyChars.addModifierException(TokenStream::OperandIsNone);
             break;
         }
 
-        if (tt == TOK_TRIPLEDOT) {
-            tokenStream.consumeKnownToken(TOK_TRIPLEDOT);
+        if (tt == TokenKind::TOK_TRIPLEDOT) {
+            tokenStream.consumeKnownToken(TokenKind::TOK_TRIPLEDOT);
             uint32_t begin = pos().begin;
 
             TokenPos innerPos;
             if (!tokenStream.peekTokenPos(&innerPos, TokenStream::Operand))
                 return null();
 
             PossibleError possibleErrorInner(*this);
             Node inner = assignExpr(InAllowed, yieldHandling, TripledotProhibited,
@@ -9521,17 +9528,17 @@ GeneralParser<ParseHandler, CharT>::obje
 
                         // Otherwise delay error reporting until we've
                         // determined whether or not we're destructuring.
                         possibleError->setPendingExpressionErrorAt(namePos,
                                                                    JSMSG_DUPLICATE_PROTO_PROPERTY);
                     }
                     seenPrototypeMutation = true;
 
-                    // Note: this occurs *only* if we observe TOK_COLON!  Only
+                    // Note: this occurs *only* if we observe TokenKind::TOK_COLON!  Only
                     // __proto__: v mutates [[Prototype]].  Getters, setters,
                     // method/generator definitions, computed property name
                     // versions of all of these, and shorthands do not.
                     if (!handler.addPrototypeMutation(literal, namePos.begin, propExpr))
                         return null();
                 } else {
                     if (!handler.isConstant(propExpr))
                         handler.setListFlag(literal, PNX_NONCONST);
@@ -9566,17 +9573,17 @@ GeneralParser<ParseHandler, CharT>::obje
                 Rooted<PropertyName*> name(context, identifierReference(yieldHandling));
                 if (!name)
                     return null();
 
                 Node lhs = identifierReference(name);
                 if (!lhs)
                     return null();
 
-                tokenStream.consumeKnownToken(TOK_ASSIGN);
+                tokenStream.consumeKnownToken(TokenKind::TOK_ASSIGN);
 
                 if (!seenCoverInitializedName) {
                     // "shorthand default" or "CoverInitializedName" syntax is
                     // only valid in the case of destructuring.
                     seenCoverInitializedName = true;
 
                     if (!possibleError) {
                         // Destructuring defaults are definitely not allowed
@@ -9610,17 +9617,17 @@ GeneralParser<ParseHandler, CharT>::obje
                 Node propExpr = handler.newAssignment(ParseNodeKind::Assign, lhs, rhs);
                 if (!propExpr)
                     return null();
 
                 if (!handler.addPropertyDefinition(literal, propName, propExpr))
                     return null();
             } else {
                 RootedAtom funName(context);
-                if (!anyChars.isCurrentTokenType(TOK_RB)) {
+                if (!anyChars.isCurrentTokenType(TokenKind::TOK_RB)) {
                     funName = propAtom;
 
                     if (propType == PropertyType::Getter || propType == PropertyType::Setter) {
                         funName = prefixAccessorName(propType, propAtom);
                         if (!funName)
                             return null();
                     }
                 }
@@ -9638,25 +9645,25 @@ GeneralParser<ParseHandler, CharT>::obje
                 if (possibleError) {
                     possibleError->setPendingDestructuringErrorAt(namePos,
                                                                   JSMSG_BAD_DESTRUCT_TARGET);
                 }
             }
         }
 
         bool matched;
-        if (!tokenStream.matchToken(&matched, TOK_COMMA, TokenStream::Operand))
+        if (!tokenStream.matchToken(&matched, TokenKind::TOK_COMMA, TokenStream::Operand))
             return null();
         if (!matched)
             break;
-        if (tt == TOK_TRIPLEDOT && possibleError)
+        if (tt == TokenKind::TOK_TRIPLEDOT && possibleError)
             possibleError->setPendingDestructuringErrorAt(pos(), JSMSG_REST_WITH_COMMA);
     }
 
-    MUST_MATCH_TOKEN_MOD_WITH_REPORT(TOK_RC, TokenStream::Operand,
+    MUST_MATCH_TOKEN_MOD_WITH_REPORT(TokenKind::TOK_RC, TokenStream::Operand,
                                      reportMissingClosing(JSMSG_CURLY_AFTER_LIST,
                                                           JSMSG_CURLY_OPENED, openedPos));
 
     handler.setEndPosition(literal, pos().end);
     return literal;
 }
 
 template <class ParseHandler, typename CharT>
@@ -9720,39 +9727,39 @@ GeneralParser<ParseHandler, CharT>::meth
     return functionDefinition(pn, toStringStart, InAllowed, yieldHandling, funName, kind,
                               generatorKind, asyncKind);
 }
 
 template <class ParseHandler, typename CharT>
 bool
 GeneralParser<ParseHandler, CharT>::tryNewTarget(Node &newTarget)
 {
-    MOZ_ASSERT(anyChars.isCurrentTokenType(TOK_NEW));
+    MOZ_ASSERT(anyChars.isCurrentTokenType(TokenKind::TOK_NEW));
 
     newTarget = null();
 
     Node newHolder = handler.newPosHolder(pos());
     if (!newHolder)
         return false;
 
     uint32_t begin = pos().begin;
 
     // |new| expects to look for an operand, so we will honor that.
     TokenKind next;
     if (!tokenStream.getToken(&next, TokenStream::Operand))
         return false;
 
     // Don't unget the token, since lookahead cannot handle someone calling
     // getToken() with a different modifier. Callers should inspect currentToken().
-    if (next != TOK_DOT)
+    if (next != TokenKind::TOK_DOT)
         return true;
 
     if (!tokenStream.getToken(&next))
         return false;
-    if (next != TOK_TARGET) {
+    if (next != TokenKind::TOK_TARGET) {
         error(JSMSG_UNEXPECTED_TOKEN, "target", TokenKindToDesc(next));
         return false;
     }
 
     if (!pc->sc()->allowNewTarget()) {
         errorAt(begin, JSMSG_BAD_NEWTARGET);
         return false;
     }
@@ -9773,136 +9780,136 @@ GeneralParser<ParseHandler, CharT>::prim
                                                 TokenKind tt, PossibleError* possibleError,
                                                 InvokedPrediction invoked /* = PredictUninvoked */)
 {
     MOZ_ASSERT(anyChars.isCurrentTokenType(tt));
     if (!CheckRecursionLimit(context))
         return null();
 
     switch (tt) {
-      case TOK_FUNCTION:
+      case TokenKind::TOK_FUNCTION:
         return functionExpr(pos().begin, expressionClosureHandling, invoked,
                             FunctionAsyncKind::SyncFunction);
 
-      case TOK_CLASS:
+      case TokenKind::TOK_CLASS:
         return classDefinition(yieldHandling, ClassExpression, NameRequired);
 
-      case TOK_LB:
+      case TokenKind::TOK_LB:
         return arrayInitializer(yieldHandling, possibleError);
 
-      case TOK_LC:
+      case TokenKind::TOK_LC:
         return objectLiteral(yieldHandling, possibleError);
 
-      case TOK_LP: {
+      case TokenKind::TOK_LP: {
         TokenKind next;
         if (!tokenStream.peekToken(&next, TokenStream::Operand))
             return null();
 
-        if (next == TOK_RP) {
+        if (next == TokenKind::TOK_RP) {
             // Not valid expression syntax, but this is valid in an arrow function
             // with no params: `() => body`.
-            tokenStream.consumeKnownToken(TOK_RP, TokenStream::Operand);
+            tokenStream.consumeKnownToken(TokenKind::TOK_RP, TokenStream::Operand);
 
             if (!tokenStream.peekToken(&next))
                 return null();
-            if (next != TOK_ARROW) {
-                error(JSMSG_UNEXPECTED_TOKEN, "expression", TokenKindToDesc(TOK_RP));
+            if (next != TokenKind::TOK_ARROW) {
+                error(JSMSG_UNEXPECTED_TOKEN, "expression", TokenKindToDesc(TokenKind::TOK_RP));
                 return null();
             }
 
             // Now just return something that will allow parsing to continue.
             // It doesn't matter what; when we reach the =>, we will rewind and
             // reparse the whole arrow function. See Parser::assignExpr.
             return handler.newNullLiteral(pos());
         }
 
         // Pass |possibleError| to support destructuring in arrow parameters.
         Node expr = exprInParens(InAllowed, yieldHandling, TripledotAllowed, possibleError);
         if (!expr)
             return null();
-        MUST_MATCH_TOKEN_MOD(TOK_RP, TokenStream::Operand, JSMSG_PAREN_IN_PAREN);
+        MUST_MATCH_TOKEN_MOD(TokenKind::TOK_RP, TokenStream::Operand, JSMSG_PAREN_IN_PAREN);
         return handler.parenthesize(expr);
       }
 
-      case TOK_TEMPLATE_HEAD:
+      case TokenKind::TOK_TEMPLATE_HEAD:
         return templateLiteral(yieldHandling);
 
-      case TOK_NO_SUBS_TEMPLATE:
+      case TokenKind::TOK_NO_SUBS_TEMPLATE:
         return noSubstitutionUntaggedTemplate();
 
-      case TOK_STRING:
+      case TokenKind::TOK_STRING:
         return stringLiteral();
 
       default: {
         if (!TokenKindIsPossibleIdentifier(tt)) {
             error(JSMSG_UNEXPECTED_TOKEN, "expression", TokenKindToDesc(tt));
             return null();
         }
 
-        if (tt == TOK_ASYNC) {
-            TokenKind nextSameLine = TOK_EOF;
+        if (tt == TokenKind::TOK_ASYNC) {
+            TokenKind nextSameLine = TokenKind::TOK_EOF;
             if (!tokenStream.peekTokenSameLine(&nextSameLine))
                 return null();
 
-            if (nextSameLine == TOK_FUNCTION) {
+            if (nextSameLine == TokenKind::TOK_FUNCTION) {
                 uint32_t toStringStart = pos().begin;
-                tokenStream.consumeKnownToken(TOK_FUNCTION);
+                tokenStream.consumeKnownToken(TokenKind::TOK_FUNCTION);
                 return functionExpr(toStringStart, expressionClosureHandling, PredictUninvoked,
                                     FunctionAsyncKind::AsyncFunction);
             }
         }
 
         Rooted<PropertyName*> name(context, identifierReference(yieldHandling));
         if (!name)
             return null();
 
         return identifierReference(name);
       }
 
-      case TOK_REGEXP:
+      case TokenKind::TOK_REGEXP:
         return newRegExp();
 
-      case TOK_NUMBER:
+      case TokenKind::TOK_NUMBER:
         return newNumber(anyChars.currentToken());
 
-      case TOK_TRUE:
+      case TokenKind::TOK_TRUE:
         return handler.newBooleanLiteral(true, pos());
-      case TOK_FALSE:
+      case TokenKind::TOK_FALSE:
         return handler.newBooleanLiteral(false, pos());
-      case TOK_THIS: {
+      case TokenKind::TOK_THIS: {
         if (pc->isFunctionBox())
             pc->functionBox()->usesThis = true;
         Node thisName = null();
         if (pc->sc()->thisBinding() == ThisBinding::Function) {
             thisName = newThisName();
             if (!thisName)
                 return null();
         }
         return handler.newThisLiteral(pos(), thisName);
       }
-      case TOK_NULL:
+      case TokenKind::TOK_NULL:
         return handler.newNullLiteral(pos());
 
-      case TOK_TRIPLEDOT: {
+      case TokenKind::TOK_TRIPLEDOT: {
         // This isn't valid expression syntax, but it's valid in an arrow
         // function as a trailing rest param: `(a, b, ...rest) => body`.  Check
         // if it's directly under
         // CoverParenthesizedExpressionAndArrowParameterList, and check for a
         // name, closing parenthesis, and arrow, and allow it only if all are
         // present.
         if (tripledotHandling != TripledotAllowed) {
             error(JSMSG_UNEXPECTED_TOKEN, "expression", TokenKindToDesc(tt));
             return null();
         }
 
         TokenKind next;
         if (!tokenStream.getToken(&next))
             return null();
 
-        if (next == TOK_LB || next == TOK_LC) {
+        if (next == TokenKind::TOK_LB || next == TokenKind::TOK_LC) {
             // Validate, but don't store the pattern right now. The whole arrow
             // function is reparsed in functionFormalParametersAndBody().
             if (!destructuringDeclaration(DeclarationKind::CoverArrowParameter, yieldHandling,
                                           next))
             {
                 return null();
             }
         } else {
@@ -9913,46 +9920,46 @@ GeneralParser<ParseHandler, CharT>::prim
             if (!TokenKindIsPossibleIdentifier(next)) {
                 error(JSMSG_UNEXPECTED_TOKEN, "rest argument name", TokenKindToDesc(next));
                 return null();
             }
         }
 
         if (!tokenStream.getToken(&next))
             return null();
-        if (next != TOK_RP) {
+        if (next != TokenKind::TOK_RP) {
             error(JSMSG_UNEXPECTED_TOKEN, "closing parenthesis", TokenKindToDesc(next));
             return null();
         }
 
         if (!tokenStream.peekToken(&next))
             return null();
-        if (next != TOK_ARROW) {
+        if (next != TokenKind::TOK_ARROW) {
             // Advance the scanner for proper error location reporting.
             tokenStream.consumeKnownToken(next);
             error(JSMSG_UNEXPECTED_TOKEN, "'=>' after argument list", TokenKindToDesc(next));
             return null();
         }
 
         anyChars.ungetToken();  // put back right paren
 
-        // Return an arbitrary expression node. See case TOK_RP above.
+        // Return an arbitrary expression node. See case TokenKind::TOK_RP above.
         return handler.newNullLiteral(pos());
       }
     }
 }
 
 template <class ParseHandler, typename CharT>
 typename ParseHandler::Node
 GeneralParser<ParseHandler, CharT>::exprInParens(InHandling inHandling,
                                                  YieldHandling yieldHandling,
                                                  TripledotHandling tripledotHandling,
                                                  PossibleError* possibleError /* = nullptr */)
 {
-    MOZ_ASSERT(anyChars.isCurrentTokenType(TOK_LP));
+    MOZ_ASSERT(anyChars.isCurrentTokenType(TokenKind::TOK_LP));
     return expr(inHandling, yieldHandling, tripledotHandling, possibleError, PredictInvoked);
 }
 
 void
 ParserBase::addTelemetry(DeprecatedLanguageExtension e)
 {
     if (context->helperThread())
         return;
--- a/js/src/frontend/Parser.h
+++ b/js/src/frontend/Parser.h
@@ -1153,17 +1153,17 @@ class GeneralParser
 
     enum ClassContext { ClassStatement, ClassExpression };
     Node classDefinition(YieldHandling yieldHandling, ClassContext classContext,
                          DefaultHandling defaultHandling);
 
     bool checkBindingIdentifier(PropertyName* ident,
                                 uint32_t offset,
                                 YieldHandling yieldHandling,
-                                TokenKind hint = TOK_LIMIT);
+                                TokenKind hint = TokenKind::TOK_LIMIT);
 
     PropertyName* labelOrIdentifierReference(YieldHandling yieldHandling);
 
     PropertyName* labelIdentifier(YieldHandling yieldHandling) {
         return labelOrIdentifierReference(yieldHandling);
     }
 
     PropertyName* identifierReference(YieldHandling yieldHandling) {
@@ -1227,17 +1227,18 @@ class GeneralParser
 
   protected:
     // Match the current token against the BindingIdentifier production with
     // the given Yield parameter.  If there is no match, report a syntax
     // error.
     PropertyName* bindingIdentifier(YieldHandling yieldHandling);
 
     bool checkLabelOrIdentifierReference(PropertyName* ident, uint32_t offset,
-                                         YieldHandling yieldHandling, TokenKind hint = TOK_LIMIT);
+                                         YieldHandling yieldHandling,
+                                         TokenKind hint = TokenKind::TOK_LIMIT);
 
     Node statementList(YieldHandling yieldHandling);
 
     bool innerFunction(Node funcNode, ParseContext* outerpc, HandleFunction fun,
                        uint32_t toStringStart, InHandling inHandling, YieldHandling yieldHandling,
                        FunctionSyntaxKind kind, GeneratorKind generatorKind,
                        FunctionAsyncKind asyncKind, bool tryAnnexB, Directives inheritedDirectives,
                        Directives* newDirectives);
--- a/js/src/frontend/ReservedWords.h
+++ b/js/src/frontend/ReservedWords.h
@@ -5,76 +5,76 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 /* A higher-order macro for enumerating reserved word tokens. */
 
 #ifndef vm_ReservedWords_h
 #define vm_ReservedWords_h
 
 #define FOR_EACH_JAVASCRIPT_RESERVED_WORD(macro) \
-    macro(false, false_, TOK_FALSE) \
-    macro(true, true_, TOK_TRUE) \
-    macro(null, null, TOK_NULL) \
+    macro(false, false_, TokenKind::TOK_FALSE) \
+    macro(true, true_, TokenKind::TOK_TRUE) \
+    macro(null, null, TokenKind::TOK_NULL) \
     \
     /* Keywords. */ \
-    macro(break, break_, TOK_BREAK) \
-    macro(case, case_, TOK_CASE) \
-    macro(catch, catch_, TOK_CATCH) \
-    macro(const, const_, TOK_CONST) \
-    macro(continue, continue_, TOK_CONTINUE) \
-    macro(debugger, debugger, TOK_DEBUGGER) \
-    macro(default, default_, TOK_DEFAULT) \
-    macro(delete, delete_, TOK_DELETE) \
-    macro(do, do_, TOK_DO) \
-    macro(else, else_, TOK_ELSE) \
-    macro(finally, finally_, TOK_FINALLY) \
-    macro(for, for_, TOK_FOR) \
-    macro(function, function, TOK_FUNCTION) \
-    macro(if, if_, TOK_IF) \
-    macro(in, in, TOK_IN) \
-    macro(instanceof, instanceof, TOK_INSTANCEOF) \
-    macro(new, new_, TOK_NEW) \
-    macro(return, return_, TOK_RETURN) \
-    macro(switch, switch_, TOK_SWITCH) \
-    macro(this, this_, TOK_THIS) \
-    macro(throw, throw_, TOK_THROW) \
-    macro(try, try_, TOK_TRY) \
-    macro(typeof, typeof_, TOK_TYPEOF) \
-    macro(var, var, TOK_VAR) \
-    macro(void, void_, TOK_VOID) \
-    macro(while, while_, TOK_WHILE) \
-    macro(with, with, TOK_WITH) \
-    macro(import, import, TOK_IMPORT) \
-    macro(export, export_, TOK_EXPORT) \
-    macro(class, class_, TOK_CLASS) \
-    macro(extends, extends, TOK_EXTENDS) \
-    macro(super, super, TOK_SUPER) \
+    macro(break, break_, TokenKind::TOK_BREAK) \
+    macro(case, case_, TokenKind::TOK_CASE) \
+    macro(catch, catch_, TokenKind::TOK_CATCH) \
+    macro(const, const_, TokenKind::TOK_CONST) \
+    macro(continue, continue_, TokenKind::TOK_CONTINUE) \
+    macro(debugger, debugger, TokenKind::TOK_DEBUGGER) \
+    macro(default, default_, TokenKind::TOK_DEFAULT) \
+    macro(delete, delete_, TokenKind::TOK_DELETE) \
+    macro(do, do_, TokenKind::TOK_DO) \
+    macro(else, else_, TokenKind::TOK_ELSE) \
+    macro(finally, finally_, TokenKind::TOK_FINALLY) \
+    macro(for, for_, TokenKind::TOK_FOR) \
+    macro(function, function, TokenKind::TOK_FUNCTION) \
+    macro(if, if_, TokenKind::TOK_IF) \
+    macro(in, in, TokenKind::TOK_IN) \
+    macro(instanceof, instanceof, TokenKind::TOK_INSTANCEOF) \
+    macro(new, new_, TokenKind::TOK_NEW) \
+    macro(return, return_, TokenKind::TOK_RETURN) \
+    macro(switch, switch_, TokenKind::TOK_SWITCH) \
+    macro(this, this_, TokenKind::TOK_THIS) \
+    macro(throw, throw_, TokenKind::TOK_THROW) \
+    macro(try, try_, TokenKind::TOK_TRY) \
+    macro(typeof, typeof_, TokenKind::TOK_TYPEOF) \
+    macro(var, var, TokenKind::TOK_VAR) \
+    macro(void, void_, TokenKind::TOK_VOID) \
+    macro(while, while_, TokenKind::TOK_WHILE) \
+    macro(with, with, TokenKind::TOK_WITH) \
+    macro(import, import, TokenKind::TOK_IMPORT) \
+    macro(export, export_, TokenKind::TOK_EXPORT) \
+    macro(class, class_, TokenKind::TOK_CLASS) \
+    macro(extends, extends, TokenKind::TOK_EXTENDS) \
+    macro(super, super, TokenKind::TOK_SUPER) \
     \
     /* Future reserved words. */ \
-    macro(enum, enum_, TOK_ENUM) \
+    macro(enum, enum_, TokenKind::TOK_ENUM) \
     \
     /* Future reserved words, but only in strict mode. */ \
-    macro(implements, implements, TOK_IMPLEMENTS) \
-    macro(interface, interface, TOK_INTERFACE) \
-    macro(package, package, TOK_PACKAGE) \
-    macro(private, private_, TOK_PRIVATE) \
-    macro(protected, protected_, TOK_PROTECTED) \
-    macro(public, public_, TOK_PUBLIC) \
+    macro(implements, implements, TokenKind::TOK_IMPLEMENTS) \
+    macro(interface, interface, TokenKind::TOK_INTERFACE) \
+    macro(package, package, TokenKind::TOK_PACKAGE) \
+    macro(private, private_, TokenKind::TOK_PRIVATE) \
+    macro(protected, protected_, TokenKind::TOK_PROTECTED) \
+    macro(public, public_, TokenKind::TOK_PUBLIC) \
     \
     /* Contextual keywords. */ \
-    macro(as, as, TOK_AS) \
-    macro(async, async, TOK_ASYNC) \
-    macro(await, await, TOK_AWAIT) \
-    macro(from, from, TOK_FROM) \
-    macro(get, get, TOK_GET) \
-    macro(let, let, TOK_LET) \
-    macro(of, of, TOK_OF) \
-    macro(set, set, TOK_SET) \
-    macro(static, static_, TOK_STATIC) \
-    macro(target, target, TOK_TARGET) \
+    macro(as, as, TokenKind::TOK_AS) \
+    macro(async, async, TokenKind::TOK_ASYNC) \
+    macro(await, await, TokenKind::TOK_AWAIT) \
+    macro(from, from, TokenKind::TOK_FROM) \
+    macro(get, get, TokenKind::TOK_GET) \
+    macro(let, let, TokenKind::TOK_LET) \
+    macro(of, of, TokenKind::TOK_OF) \
+    macro(set, set, TokenKind::TOK_SET) \
+    macro(static, static_, TokenKind::TOK_STATIC) \
+    macro(target, target, TokenKind::TOK_TARGET) \
     /* \
      * Yield is a token inside function*.  Outside of a function*, it is a \
      * future reserved word in strict mode, but a keyword in JS1.7 even \
      * when strict.  Punt logic to parser. \
      */ \
-    macro(yield, yield, TOK_YIELD)
+    macro(yield, yield, TokenKind::TOK_YIELD)
 
 #endif /* vm_ReservedWords_h */
--- a/js/src/frontend/TokenKind.h
+++ b/js/src/frontend/TokenKind.h
@@ -230,99 +230,99 @@
 #define FOR_EACH_TOKEN_KIND(macro) \
     FOR_EACH_TOKEN_KIND_WITH_RANGE(macro, TOKEN_KIND_RANGE_EMIT_NONE)
 
 namespace js {
 namespace frontend {
 
 // Values of this type are used to index into arrays such as isExprEnding[],
 // so the first value must be zero.
-enum TokenKind {
+enum class TokenKind {
 #define EMIT_ENUM(name, desc) TOK_##name,
 #define EMIT_ENUM_RANGE(name, value) TOK_##name = TOK_##value,
     FOR_EACH_TOKEN_KIND_WITH_RANGE(EMIT_ENUM, EMIT_ENUM_RANGE)
 #undef EMIT_ENUM
 #undef EMIT_ENUM_RANGE
     TOK_LIMIT                      // domain size
 };
 
 inline bool
 TokenKindIsBinaryOp(TokenKind tt)
 {
-    return TOK_BINOP_FIRST <= tt && tt <= TOK_BINOP_LAST;
+    return TokenKind::TOK_BINOP_FIRST <= tt && tt <= TokenKind::TOK_BINOP_LAST;
 }
 
 inline bool
 TokenKindIsEquality(TokenKind tt)
 {
-    return TOK_EQUALITY_START <= tt && tt <= TOK_EQUALITY_LAST;
+    return TokenKind::TOK_EQUALITY_START <= tt && tt <= TokenKind::TOK_EQUALITY_LAST;
 }
 
 inline bool
 TokenKindIsRelational(TokenKind tt)
 {
-    return TOK_RELOP_START <= tt && tt <= TOK_RELOP_LAST;
+    return TokenKind::TOK_RELOP_START <= tt && tt <= TokenKind::TOK_RELOP_LAST;
 }
 
 inline bool
 TokenKindIsShift(TokenKind tt)
 {
-    return TOK_SHIFTOP_START <= tt && tt <= TOK_SHIFTOP_LAST;
+    return TokenKind::TOK_SHIFTOP_START <= tt && tt <= TokenKind::TOK_SHIFTOP_LAST;
 }
 
 inline bool
 TokenKindIsAssignment(TokenKind tt)
 {
-    return TOK_ASSIGNMENT_START <= tt && tt <= TOK_ASSIGNMENT_LAST;
+    return TokenKind::TOK_ASSIGNMENT_START <= tt && tt <= TokenKind::TOK_ASSIGNMENT_LAST;
 }
 
 inline MOZ_MUST_USE bool
 TokenKindIsKeyword(TokenKind tt)
 {
-    return (TOK_KEYWORD_FIRST <= tt && tt <= TOK_KEYWORD_LAST) ||
-           (TOK_KEYWORD_BINOP_FIRST <= tt && tt <= TOK_KEYWORD_BINOP_LAST) ||
-           (TOK_KEYWORD_UNOP_FIRST <= tt && tt <= TOK_KEYWORD_UNOP_LAST);
+    return (TokenKind::TOK_KEYWORD_FIRST <= tt && tt <= TokenKind::TOK_KEYWORD_LAST) ||
+           (TokenKind::TOK_KEYWORD_BINOP_FIRST <= tt && tt <= TokenKind::TOK_KEYWORD_BINOP_LAST) ||
+           (TokenKind::TOK_KEYWORD_UNOP_FIRST <= tt && tt <= TokenKind::TOK_KEYWORD_UNOP_LAST);
 }
 
 inline MOZ_MUST_USE bool
 TokenKindIsContextualKeyword(TokenKind tt)
 {
-    return TOK_CONTEXTUAL_KEYWORD_FIRST <= tt && tt <= TOK_CONTEXTUAL_KEYWORD_LAST;
+    return TokenKind::TOK_CONTEXTUAL_KEYWORD_FIRST <= tt && tt <= TokenKind::TOK_CONTEXTUAL_KEYWORD_LAST;
 }
 
 inline MOZ_MUST_USE bool
 TokenKindIsFutureReservedWord(TokenKind tt)
 {
-    return TOK_FUTURE_RESERVED_KEYWORD_FIRST <= tt && tt <= TOK_FUTURE_RESERVED_KEYWORD_LAST;
+    return TokenKind::TOK_FUTURE_RESERVED_KEYWORD_FIRST <= tt && tt <= TokenKind::TOK_FUTURE_RESERVED_KEYWORD_LAST;
 }
 
 inline MOZ_MUST_USE bool
 TokenKindIsStrictReservedWord(TokenKind tt)
 {
-    return TOK_STRICT_RESERVED_KEYWORD_FIRST <= tt && tt <= TOK_STRICT_RESERVED_KEYWORD_LAST;
+    return TokenKind::TOK_STRICT_RESERVED_KEYWORD_FIRST <= tt && tt <= TokenKind::TOK_STRICT_RESERVED_KEYWORD_LAST;
 }
 
 inline MOZ_MUST_USE bool
 TokenKindIsReservedWordLiteral(TokenKind tt)
 {
-    return TOK_RESERVED_WORD_LITERAL_FIRST <= tt && tt <= TOK_RESERVED_WORD_LITERAL_LAST;
+    return TokenKind::TOK_RESERVED_WORD_LITERAL_FIRST <= tt && tt <= TokenKind::TOK_RESERVED_WORD_LITERAL_LAST;
 }
 
 inline MOZ_MUST_USE bool
 TokenKindIsReservedWord(TokenKind tt)
 {
     return TokenKindIsKeyword(tt) ||
            TokenKindIsFutureReservedWord(tt) ||
            TokenKindIsReservedWordLiteral(tt);
 }
 
 inline MOZ_MUST_USE bool
 TokenKindIsPossibleIdentifier(TokenKind tt)
 {
-    return tt == TOK_NAME ||
+    return tt == TokenKind::TOK_NAME ||
            TokenKindIsContextualKeyword(tt) ||
            TokenKindIsStrictReservedWord(tt);
 }
 
 inline MOZ_MUST_USE bool
 TokenKindIsPossibleIdentifierName(TokenKind tt)
 {
     return TokenKindIsPossibleIdentifier(tt) ||
--- a/js/src/frontend/TokenStream.cpp
+++ b/js/src/frontend/TokenStream.cpp
@@ -205,46 +205,46 @@ IsKeyword(JSLinearString* str)
 }
 
 TokenKind
 ReservedWordTokenKind(PropertyName* str)
 {
     if (const ReservedWordInfo* rw = FindReservedWord(str))
         return rw->tokentype;
 
-    return TOK_NAME;
+    return TokenKind::TOK_NAME;
 }
 
 const char*
 ReservedWordToCharZ(PropertyName* str)
 {
     if (const ReservedWordInfo* rw = FindReservedWord(str))
         return ReservedWordToCharZ(rw->tokentype);
 
     return nullptr;
 }
 
 const char*
 ReservedWordToCharZ(TokenKind tt)
 {
-    MOZ_ASSERT(tt != TOK_NAME);
+    MOZ_ASSERT(tt != TokenKind::TOK_NAME);
     switch (tt) {
 #define EMIT_CASE(word, name, type) case type: return js_##word##_str;
       FOR_EACH_JAVASCRIPT_RESERVED_WORD(EMIT_CASE)
 #undef EMIT_CASE
       default:
         MOZ_ASSERT_UNREACHABLE("Not a reserved word PropertyName.");
     }
     return nullptr;
 }
 
 PropertyName*
 TokenStreamAnyChars::reservedWordToPropertyName(TokenKind tt) const
 {
-    MOZ_ASSERT(tt != TOK_NAME);
+    MOZ_ASSERT(tt != TokenKind::TOK_NAME);
     switch (tt) {
 #define EMIT_CASE(word, name, type) case type: return cx->names().name;
       FOR_EACH_JAVASCRIPT_RESERVED_WORD(EMIT_CASE)
 #undef EMIT_CASE
       default:
         MOZ_ASSERT_UNREACHABLE("Not a reserved word TokenKind.");
     }
     return nullptr;
@@ -421,22 +421,22 @@ TokenStreamAnyChars::TokenStreamAnyChars
     strictModeGetter(smg)
 {
     // Nb: the following tables could be static, but initializing them here is
     // much easier.  Don't worry, the time to initialize them for each
     // TokenStream is trivial.  See bug 639420.
 
     // See Parser::assignExpr() for an explanation of isExprEnding[].
     PodArrayZero(isExprEnding);
-    isExprEnding[TOK_COMMA] = 1;
-    isExprEnding[TOK_SEMI] = 1;
-    isExprEnding[TOK_COLON] = 1;
-    isExprEnding[TOK_RP] = 1;
-    isExprEnding[TOK_RB] = 1;
-    isExprEnding[TOK_RC] = 1;
+    isExprEnding[size_t(TokenKind::TOK_COMMA)] = 1;
+    isExprEnding[size_t(TokenKind::TOK_SEMI)] = 1;
+    isExprEnding[size_t(TokenKind::TOK_COLON)] = 1;
+    isExprEnding[size_t(TokenKind::TOK_RP)] = 1;
+    isExprEnding[size_t(TokenKind::TOK_RB)] = 1;
+    isExprEnding[size_t(TokenKind::TOK_RC)] = 1;
 }
 
 template<typename CharT>
 TokenStreamCharsBase<CharT>::TokenStreamCharsBase(JSContext* cx, const CharT* chars, size_t length,
                                                   size_t startOffset)
   : userbuf(chars, length, startOffset),
     tokenbuf(cx)
 {}
@@ -791,17 +791,17 @@ TokenStreamAnyChars::fillExcludingContex
     err->filename = filename_;
     srcCoords.lineNumAndColumnIndex(offset, &err->lineNumber, &err->columnNumber);
     return true;
 }
 
 bool
 TokenStreamAnyChars::hasTokenizationStarted() const
 {
-    return isCurrentTokenType(TOK_EOF) && !isEOF();
+    return isCurrentTokenType(TokenKind::TOK_EOF) && !isEOF();
 }
 
 void
 TokenStreamAnyChars::lineAndColumnAt(size_t offset, uint32_t* line, uint32_t* column) const
 {
     srcCoords.lineNumAndColumnIndex(offset, line, column);
 }
 
@@ -1247,19 +1247,19 @@ TokenStreamSpecific<CharT, AnyCharsAcces
 
     return tp;
 }
 
 #ifdef DEBUG
 static bool
 IsTokenSane(Token* tp)
 {
-    // Nb: TOK_EOL should never be used in an actual Token;  it should only be
-    // returned as a TokenKind from peekTokenSameLine().
-    if (tp->type >= TOK_LIMIT || tp->type == TOK_EOL)
+    // Nb: TokenKind::TOK_EOL should never be used in an actual Token;
+    // it should only be returned as a TokenKind from peekTokenSameLine().
+    if (tp->type >= TokenKind::TOK_LIMIT || tp->type == TokenKind::TOK_EOL)
         return false;
 
     if (tp->pos.end < tp->pos.begin)
         return false;
 
     return true;
 }
 #endif
@@ -1351,23 +1351,23 @@ enum FirstCharKind {
     // token that cannot also be a prefix of a longer token.  E.g. ';' has the
     // OneChar kind, but '+' does not, because '++' and '+=' are valid longer tokens
     // that begin with '+'.
     //
     // The few token kinds satisfying these properties cover roughly 35--45%
     // of the tokens seen in practice.
     //
     // We represent the 'OneChar' kind with any positive value less than
-    // TOK_LIMIT.  This representation lets us associate each one-char token
-    // char16_t with a TokenKind and thus avoid a subsequent char16_t-to-TokenKind
-    // conversion.
+    // TokenKind::TOK_LIMIT.  This representation lets us associate
+    // each one-char token char16_t with a TokenKind and thus avoid
+    // a subsequent char16_t-to-TokenKind conversion.
     OneChar_Min = 0,
-    OneChar_Max = TOK_LIMIT - 1,
+    OneChar_Max = size_t(TokenKind::TOK_LIMIT) - 1,
 
-    Space = TOK_LIMIT,
+    Space = size_t(TokenKind::TOK_LIMIT),
     Ident,
     Dec,
     String,
     EOL,
     BasePrefix,
     Other,
 
     LastCharKind = Other
@@ -1380,40 +1380,56 @@ enum FirstCharKind {
 // Equals:  61: '='
 // String:  34, 39: '"', '\''
 // Dec:     49..57: '1'..'9'
 // Plus:    43: '+'
 // BasePrefix:  48: '0'
 // Space:   9, 11, 12, 32: '\t', '\v', '\f', ' '
 // EOL:     10, 13: '\n', '\r'
 //
-#define T_COMMA     TOK_COMMA
-#define T_COLON     TOK_COLON
-#define T_BITNOT    TOK_BITNOT
+#define T_COMMA     size_t(TokenKind::TOK_COMMA)
+#define T_COLON     size_t(TokenKind::TOK_COLON)
+#define T_BITNOT    size_t(TokenKind::TOK_BITNOT)
+#define T_LP        size_t(TokenKind::TOK_LP)
+#define T_RP        size_t(TokenKind::TOK_RP)
+#define T_SEMI      size_t(TokenKind::TOK_SEMI)
+#define T_HOOK      size_t(TokenKind::TOK_HOOK)
+#define T_LB        size_t(TokenKind::TOK_LB)
+#define T_RB        size_t(TokenKind::TOK_RB)
+#define T_LC        size_t(TokenKind::TOK_LC)
+#define T_RC        size_t(TokenKind::TOK_RC)
 #define Templat     String
 #define _______     Other
 static const uint8_t firstCharKinds[] = {
 /*         0        1        2        3        4        5        6        7        8        9    */
 /*   0+ */ _______, _______, _______, _______, _______, _______, _______, _______, _______,   Space,
 /*  10+ */     EOL,   Space,   Space,     EOL, _______, _______, _______, _______, _______, _______,
 /*  20+ */ _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
 /*  30+ */ _______, _______,   Space, _______,  String, _______,   Ident, _______, _______,  String,
-/*  40+ */  TOK_LP,  TOK_RP, _______, _______, T_COMMA,_______,  _______, _______,BasePrefix,  Dec,
-/*  50+ */     Dec,     Dec,     Dec,     Dec,     Dec,     Dec,     Dec,    Dec,  T_COLON,TOK_SEMI,
-/*  60+ */ _______, _______, _______,TOK_HOOK, _______,   Ident,   Ident,   Ident,   Ident,   Ident,
+/*  40+ */    T_LP,    T_RP, _______, _______, T_COMMA,_______,  _______, _______,BasePrefix,  Dec,
+/*  50+ */     Dec,     Dec,     Dec,     Dec,     Dec,     Dec,     Dec,    Dec,  T_COLON,  T_SEMI,
+/*  60+ */ _______, _______, _______,  T_HOOK, _______,   Ident,   Ident,   Ident,   Ident,   Ident,
 /*  70+ */   Ident,   Ident,   Ident,   Ident,   Ident,   Ident,   Ident,   Ident,   Ident,   Ident,
 /*  80+ */   Ident,   Ident,   Ident,   Ident,   Ident,   Ident,   Ident,   Ident,   Ident,   Ident,
-/*  90+ */   Ident,  TOK_LB, _______,  TOK_RB, _______,   Ident, Templat,   Ident,   Ident,   Ident,
+/*  90+ */   Ident,    T_LB, _______,    T_RB, _______,   Ident, Templat,   Ident,   Ident,   Ident,
 /* 100+ */   Ident,   Ident,   Ident,   Ident,   Ident,   Ident,   Ident,   Ident,   Ident,   Ident,
 /* 110+ */   Ident,   Ident,   Ident,   Ident,   Ident,   Ident,   Ident,   Ident,   Ident,   Ident,
-/* 120+ */   Ident,   Ident,   Ident,  TOK_LC, _______,  TOK_RC,T_BITNOT, _______
+/* 120+ */   Ident,   Ident,   Ident,    T_LC, _______,    T_RC,T_BITNOT, _______
 };
 #undef T_COMMA
 #undef T_COLON
 #undef T_BITNOT
+#undef T_LP
+#undef T_RP
+#undef T_SEMI
+#undef T_HOOK
+#undef T_LB
+#undef T_RB
+#undef T_LC
+#undef T_RC
 #undef Templat
 #undef _______
 
 static_assert(LastCharKind < (1 << (sizeof(firstCharKinds[0]) * 8)),
               "Elements of firstCharKinds[] are too small");
 
 template<typename CharT, class AnyCharsAccess>
 MOZ_MUST_USE bool
@@ -1435,17 +1451,17 @@ TokenStreamSpecific<CharT, AnyCharsAcces
         if (!getStringOrTemplateToken('`', &tp))
             goto error;
         goto out;
     }
 
   retry:
     if (MOZ_UNLIKELY(!userbuf.hasRawChars())) {
         tp = newToken(0);
-        tp->type = TOK_EOF;
+        tp->type = TokenKind::TOK_EOF;
         anyCharsAccess().flags.isEOF = true;
         goto out;
     }
 
     c = userbuf.getRawChar();
     MOZ_ASSERT(c != EOF);
 
     // Chars not in the range 0..127 are rare.  Getting them out of the way
@@ -1575,17 +1591,17 @@ TokenStreamSpecific<CharT, AnyCharsAcces
                 tp->type = rw->tokentype;
                 goto out;
             }
         }
 
         JSAtom* atom = atomizeChars(anyCharsAccess().cx, chars, length);
         if (!atom)
             goto error;
-        tp->type = TOK_NAME;
+        tp->type = TokenKind::TOK_NAME;
         tp->setName(atom->asPropertyName());
         goto out;
     }
 
     // Look for a decimal number.
     //
     if (c1kind == Dec) {
         tp = newToken(-1);
@@ -1648,17 +1664,17 @@ TokenStreamSpecific<CharT, AnyCharsAcces
         } else {
             const CharT* dummy;
             if (!js_strtod(anyCharsAccess().cx, numStart, userbuf.addressOfNextRawChar(),
                            &dummy, &dval))
             {
                 goto error;
             }
         }
-        tp->type = TOK_NUMBER;
+        tp->type = TokenKind::TOK_NUMBER;
         tp->setNumber(dval, decimalPoint);
         goto out;
     }
 
     // Look for a string or a template string.
     //
     if (c1kind == String) {
         if (!getStringOrTemplateToken(c, &tp))
@@ -1763,17 +1779,17 @@ TokenStreamSpecific<CharT, AnyCharsAcces
         double dval;
         const char16_t* dummy;
         if (!GetPrefixInteger(anyCharsAccess().cx, numStart, userbuf.addressOfNextRawChar(),
                               radix, &dummy, &dval))
         {
             goto error;
         }
 
-        tp->type = TOK_NUMBER;
+        tp->type = TokenKind::TOK_NUMBER;
         tp->setNumber(dval, NoDecimal);
         goto out;
     }
 
     // This handles everything else.
     //
     MOZ_ASSERT(c1kind == Other);
     tp = newToken(-1);
@@ -1783,114 +1799,114 @@ TokenStreamSpecific<CharT, AnyCharsAcces
         if (JS7_ISDEC(c)) {
             numStart = userbuf.addressOfNextRawChar() - 2;
             decimalPoint = HasDecimal;
             hasExp = false;
             goto decimal_dot;
         }
         if (c == '.') {
             if (matchChar('.')) {
-                tp->type = TOK_TRIPLEDOT;
+                tp->type = TokenKind::TOK_TRIPLEDOT;
                 goto out;
             }
         }
         ungetCharIgnoreEOL(c);
-        tp->type = TOK_DOT;
+        tp->type = TokenKind::TOK_DOT;
         goto out;
 
       case '=':
         if (matchChar('='))
-            tp->type = matchChar('=') ? TOK_STRICTEQ : TOK_EQ;
+            tp->type = matchChar('=') ? TokenKind::TOK_STRICTEQ : TokenKind::TOK_EQ;
         else if (matchChar('>'))
-            tp->type = TOK_ARROW;
+            tp->type = TokenKind::TOK_ARROW;
         else
-            tp->type = TOK_ASSIGN;
+            tp->type = TokenKind::TOK_ASSIGN;
         goto out;
 
       case '+':
         if (matchChar('+'))
-            tp->type = TOK_INC;
+            tp->type = TokenKind::TOK_INC;
         else
-            tp->type = matchChar('=') ? TOK_ADDASSIGN : TOK_ADD;
+            tp->type = matchChar('=') ? TokenKind::TOK_ADDASSIGN : TokenKind::TOK_ADD;
         goto out;
 
       case '\\': {
         uint32_t escapeLength = matchUnicodeEscapeIdStart(&qc);
         if (escapeLength > 0) {
             identStart = userbuf.addressOfNextRawChar() - escapeLength - 1;
             hadUnicodeEscape = true;
             goto identifier;
         }
         goto badchar;
       }
 
       case '|':
         if (matchChar('|'))
-            tp->type = TOK_OR;
+            tp->type = TokenKind::TOK_OR;
 #ifdef ENABLE_PIPELINE_OPERATOR
         else if (matchChar('>'))
-            tp->type = TOK_PIPELINE;
+            tp->type = TokenKind::TOK_PIPELINE;
 #endif
         else
-            tp->type = matchChar('=') ? TOK_BITORASSIGN : TOK_BITOR;
+            tp->type = matchChar('=') ? TokenKind::TOK_BITORASSIGN : TokenKind::TOK_BITOR;
         goto out;
 
       case '^':
-        tp->type = matchChar('=') ? TOK_BITXORASSIGN : TOK_BITXOR;
+        tp->type = matchChar('=') ? TokenKind::TOK_BITXORASSIGN : TokenKind::TOK_BITXOR;
         goto out;
 
       case '&':
         if (matchChar('&'))
-            tp->type = TOK_AND;
+            tp->type = TokenKind::TOK_AND;
         else
-            tp->type = matchChar('=') ? TOK_BITANDASSIGN : TOK_BITAND;
+            tp->type = matchChar('=') ? TokenKind::TOK_BITANDASSIGN : TokenKind::TOK_BITAND;
         goto out;
 
       case '!':
         if (matchChar('='))
-            tp->type = matchChar('=') ? TOK_STRICTNE : TOK_NE;
+            tp->type = matchChar('=') ? TokenKind::TOK_STRICTNE : TokenKind::TOK_NE;
         else
-            tp->type = TOK_NOT;
+            tp->type = TokenKind::TOK_NOT;
         goto out;
 
       case '<':
         if (anyCharsAccess().options().allowHTMLComments) {
             // Treat HTML begin-comment as comment-till-end-of-line.
             if (matchChar('!')) {
                 if (matchChar('-')) {
                     if (matchChar('-'))
                         goto skipline;
                     ungetChar('-');
                 }
                 ungetChar('!');
             }
         }
         if (matchChar('<')) {
-            tp->type = matchChar('=') ? TOK_LSHASSIGN : TOK_LSH;
+            tp->type = matchChar('=') ? TokenKind::TOK_LSHASSIGN : TokenKind::TOK_LSH;
         } else {
-            tp->type = matchChar('=') ? TOK_LE : TOK_LT;
+            tp->type = matchChar('=') ? TokenKind::TOK_LE : TokenKind::TOK_LT;
         }
         goto out;
 
       case '>':
         if (matchChar('>')) {
             if (matchChar('>'))
-                tp->type = matchChar('=') ? TOK_URSHASSIGN : TOK_URSH;
+                tp->type = matchChar('=') ? TokenKind::TOK_URSHASSIGN : TokenKind::TOK_URSH;
             else
-                tp->type = matchChar('=') ? TOK_RSHASSIGN : TOK_RSH;
+                tp->type = matchChar('=') ? TokenKind::TOK_RSHASSIGN : TokenKind::TOK_RSH;
         } else {
-            tp->type = matchChar('=') ? TOK_GE : TOK_GT;
+            tp->type = matchChar('=') ? TokenKind::TOK_GE : TokenKind::TOK_GT;
         }
         goto out;
 
       case '*':
         if (matchChar('*'))
-            tp->type = matchChar('=') ? TOK_POWASSIGN : TOK_POW;
+            tp->type = matchChar('=') ? TokenKind::TOK_POWASSIGN : TokenKind::TOK_POW;
         else
-            tp->type = matchChar('=') ? TOK_MULASSIGN : TOK_MUL;
+            tp->type = matchChar('=') ? TokenKind::TOK_MULASSIGN : TokenKind::TOK_MUL;
         goto out;
 
       case '/':
         // Look for a single-line comment.
         if (matchChar('/')) {
             if (!peekChar(&c))
                 goto error;
             if (c == '@' || c == '#') {
@@ -2000,44 +2016,44 @@ TokenStreamSpecific<CharT, AnyCharsAcces
             if (JS7_ISLET(c)) {
                 char buf[2] = { '\0', '\0' };
                 tp->pos.begin += length + 1;
                 buf[0] = char(c);
                 reportError(JSMSG_BAD_REGEXP_FLAG, buf);
                 consumeKnownChar(c);
                 goto error;
             }
-            tp->type = TOK_REGEXP;
+            tp->type = TokenKind::TOK_REGEXP;
             tp->setRegExpFlags(reflags);
             goto out;
         }
 
-        tp->type = matchChar('=') ? TOK_DIVASSIGN : TOK_DIV;
+        tp->type = matchChar('=') ? TokenKind::TOK_DIVASSIGN : TokenKind::TOK_DIV;
         goto out;
 
       case '%':
-        tp->type = matchChar('=') ? TOK_MODASSIGN : TOK_MOD;
+        tp->type = matchChar('=') ? TokenKind::TOK_MODASSIGN : TokenKind::TOK_MOD;
         goto out;
 
       case '-':
         if (matchChar('-')) {
             if (anyCharsAccess().options().allowHTMLComments &&
                 !anyCharsAccess().flags.isDirtyLine)
             {
                 int32_t c2;
                 if (!peekChar(&c2))
                     goto error;
 
                 if (c2 == '>')
                     goto skipline;
             }
 
-            tp->type = TOK_DEC;
+            tp->type = TokenKind::TOK_DEC;
         } else {
-            tp->type = matchChar('=') ? TOK_SUBASSIGN : TOK_SUB;
+            tp->type = matchChar('=') ? TokenKind::TOK_SUBASSIGN : TokenKind::TOK_SUB;
         }
         goto out;
 
       badchar:
       default:
         reportError(JSMSG_ILLEGAL_CHARACTER);
         goto error;
     }
@@ -2315,52 +2331,52 @@ TokenStreamSpecific<CharT, AnyCharsAcces
         }
     }
 
     JSAtom* atom = atomizeChars(anyCharsAccess().cx, tokenbuf.begin(), tokenbuf.length());
     if (!atom)
         return false;
 
     if (!parsingTemplate) {
-        (*tp)->type = TOK_STRING;
+        (*tp)->type = TokenKind::TOK_STRING;
     } else {
         if (c == '$' && nc == '{')
-            (*tp)->type = TOK_TEMPLATE_HEAD;
+            (*tp)->type = TokenKind::TOK_TEMPLATE_HEAD;
         else
-            (*tp)->type = TOK_NO_SUBS_TEMPLATE;
+            (*tp)->type = TokenKind::TOK_NO_SUBS_TEMPLATE;
     }
 
     (*tp)->setAtom(atom);
     return true;
 }
 
 const char*
 TokenKindToDesc(TokenKind tt)
 {
     switch (tt) {
-#define EMIT_CASE(name, desc) case TOK_##name: return desc;
+#define EMIT_CASE(name, desc) case TokenKind::TOK_##name: return desc;
       FOR_EACH_TOKEN_KIND(EMIT_CASE)
 #undef EMIT_CASE
-      case TOK_LIMIT:
-        MOZ_ASSERT_UNREACHABLE("TOK_LIMIT should not be passed.");
+      case TokenKind::TOK_LIMIT:
+        MOZ_ASSERT_UNREACHABLE("TokenKind::TOK_LIMIT should not be passed.");
         break;
     }
 
     return "<bad TokenKind>";
 }
 
 #ifdef DEBUG
 const char*
 TokenKindToString(TokenKind tt)
 {
     switch (tt) {
-#define EMIT_CASE(name, desc) case TOK_##name: return "TOK_" #name;
+#define EMIT_CASE(name, desc) case TokenKind::TOK_##name: return "TokenKind::TOK_" #name;
       FOR_EACH_TOKEN_KIND(EMIT_CASE)
 #undef EMIT_CASE
-      case TOK_LIMIT: break;
+      case TokenKind::TOK_LIMIT: break;
     }
 
     return "<bad TokenKind>";
 }
 #endif
 
 template class frontend::TokenStreamCharsBase<char16_t>;
 
--- a/js/src/frontend/TokenStream.h
+++ b/js/src/frontend/TokenStream.h
@@ -308,66 +308,66 @@ struct Token
 #ifdef DEBUG
     Modifier modifier;                  // Modifier used to get this token
     ModifierException modifierException; // Exception for this modifier
 #endif
 
     // Mutators
 
     void setName(PropertyName* name) {
-        MOZ_ASSERT(type == TOK_NAME);
+        MOZ_ASSERT(type == TokenKind::TOK_NAME);
         u.name = name;
     }
 
     void setAtom(JSAtom* atom) {
-        MOZ_ASSERT(type == TOK_STRING ||
-                   type == TOK_TEMPLATE_HEAD ||
-                   type == TOK_NO_SUBS_TEMPLATE);
+        MOZ_ASSERT(type == TokenKind::TOK_STRING ||
+                   type == TokenKind::TOK_TEMPLATE_HEAD ||
+                   type == TokenKind::TOK_NO_SUBS_TEMPLATE);
         u.atom = atom;
     }
 
     void setRegExpFlags(RegExpFlag flags) {
-        MOZ_ASSERT(type == TOK_REGEXP);
+        MOZ_ASSERT(type == TokenKind::TOK_REGEXP);
         MOZ_ASSERT((flags & AllFlags) == flags);
         u.reflags = flags;
     }
 
     void setNumber(double n, DecimalPoint decimalPoint) {
-        MOZ_ASSERT(type == TOK_NUMBER);
+        MOZ_ASSERT(type == TokenKind::TOK_NUMBER);
         u.number.value = n;
         u.number.decimalPoint = decimalPoint;
     }
 
     // Type-safe accessors
 
     PropertyName* name() const {
-        MOZ_ASSERT(type == TOK_NAME);
+        MOZ_ASSERT(type == TokenKind::TOK_NAME);
         return u.name->JSAtom::asPropertyName(); // poor-man's type verification
     }
 
     JSAtom* atom() const {
-        MOZ_ASSERT(type == TOK_STRING ||
-                   type == TOK_TEMPLATE_HEAD ||
-                   type == TOK_NO_SUBS_TEMPLATE);
+        MOZ_ASSERT(type == TokenKind::TOK_STRING ||
+                   type == TokenKind::TOK_TEMPLATE_HEAD ||
+                   type == TokenKind::TOK_NO_SUBS_TEMPLATE);
         return u.atom;
     }
 
     RegExpFlag regExpFlags() const {
-        MOZ_ASSERT(type == TOK_REGEXP);
+        MOZ_ASSERT(type == TokenKind::TOK_REGEXP);
         MOZ_ASSERT((u.reflags & AllFlags) == u.reflags);
         return u.reflags;
     }
 
     double number() const {
-        MOZ_ASSERT(type == TOK_NUMBER);
+        MOZ_ASSERT(type == TokenKind::TOK_NUMBER);
         return u.number.value;
     }
 
     DecimalPoint decimalPoint() const {
-        MOZ_ASSERT(type == TOK_NUMBER);
+        MOZ_ASSERT(type == TokenKind::TOK_NUMBER);
         return u.number.decimalPoint;
     }
 };
 
 extern TokenKind
 ReservedWordTokenKind(PropertyName* str);
 
 extern const char*
@@ -485,35 +485,35 @@ class TokenStreamAnyChars
 
   private:
     PropertyName* reservedWordToPropertyName(TokenKind tt) const;
 
     void undoGetChar();
 
   public:
     PropertyName* currentName() const {
-        if (isCurrentTokenType(TOK_NAME))
+        if (isCurrentTokenType(TokenKind::TOK_NAME))
             return currentToken().name();
 
         MOZ_ASSERT(TokenKindIsPossibleIdentifierName(currentToken().type));
         return reservedWordToPropertyName(currentToken().type);
     }
 
     bool currentNameHasEscapes() const {
-        if (isCurrentTokenType(TOK_NAME)) {
+        if (isCurrentTokenType(TokenKind::TOK_NAME)) {
             TokenPos pos = currentToken().pos;
             return (pos.end - pos.begin) != currentToken().name()->length();
         }
 
         MOZ_ASSERT(TokenKindIsPossibleIdentifierName(currentToken().type));
         return false;
     }
 
     PropertyName* nextName() const {
-        if (nextToken().type != TOK_NAME)
+        if (nextToken().type != TokenKind::TOK_NAME)
             return nextToken().name();
 
         MOZ_ASSERT(TokenKindIsPossibleIdentifierName(nextToken().type));
         return reservedWordToPropertyName(nextToken().type);
     }
 
     bool isCurrentTokenAssignment() const {
         return TokenKindIsAssignment(currentToken().type);
@@ -560,33 +560,33 @@ class TokenStreamAnyChars
         // after parsing all of an arrow function.
         if (next.modifierException == modifierException)
             return;
 
         if (next.modifierException == NoneIsOperand) {
             // Token after yield expression without operand already has
             // NoneIsOperand exception.
             MOZ_ASSERT(modifierException == OperandIsNone);
-            MOZ_ASSERT(next.type != TOK_DIV,
+            MOZ_ASSERT(next.type != TokenKind::TOK_DIV,
                        "next token requires contextual specifier to be parsed unambiguously");
 
             // Do not update modifierException.
             return;
         }
 
         MOZ_ASSERT(next.modifierException == NoException);
         switch (modifierException) {
           case NoneIsOperand:
             MOZ_ASSERT(next.modifier == Operand);
-            MOZ_ASSERT(next.type != TOK_DIV,
+            MOZ_ASSERT(next.type != TokenKind::TOK_DIV,
                        "next token requires contextual specifier to be parsed unambiguously");
             break;
           case OperandIsNone:
             MOZ_ASSERT(next.modifier == None);
-            MOZ_ASSERT(next.type != TOK_DIV && next.type != TOK_REGEXP,
+            MOZ_ASSERT(next.type != TokenKind::TOK_DIV && next.type != TokenKind::TOK_REGEXP,
                        "next token requires contextual specifier to be parsed unambiguously");
             break;
           default:
             MOZ_CRASH("unexpected modifier exception");
         }
         tokens[(cursor + 1) & ntokensMask].modifierException = modifierException;
 #endif
     }
@@ -765,17 +765,17 @@ class TokenStreamAnyChars
     unsigned            lookahead;          // count of lookahead tokens
     unsigned            lineno;             // current line number
     TokenStreamFlags    flags;              // flags -- see above
     size_t              linebase;           // start of current line
     size_t              prevLinebase;       // start of previous line;  size_t(-1) if on the first line
     const char*         filename_;          // input filename or null
     UniqueTwoByteChars  displayURL_;        // the user's requested source URL or null
     UniqueTwoByteChars  sourceMapURL_;      // source map's filename or null
-    uint8_t             isExprEnding[TOK_LIMIT];// which tokens definitely terminate exprs?
+    uint8_t             isExprEnding[size_t(TokenKind::TOK_LIMIT)];// which tokens definitely terminate exprs?
     JSContext* const    cx;
     bool                mutedErrors;
     StrictModeGetter*   strictModeGetter;  // used to test for strict mode
 };
 
 template<typename CharT>
 class TokenStreamCharsBase
 {
@@ -1111,21 +1111,21 @@ class MOZ_STACK_CLASS TokenStreamSpecifi
     bool reportStrictModeErrorNumberVA(UniquePtr<JSErrorNotes> notes, uint32_t offset,
                                        bool strictMode, unsigned errorNumber, va_list* args);
     bool reportExtraWarningErrorNumberVA(UniquePtr<JSErrorNotes> notes, uint32_t offset,
                                          unsigned errorNumber, va_list* args);
 
     JSAtom* getRawTemplateStringAtom() {
         TokenStreamAnyChars& anyChars = anyCharsAccess();
 
-        MOZ_ASSERT(anyChars.currentToken().type == TOK_TEMPLATE_HEAD ||
-                   anyChars.currentToken().type == TOK_NO_SUBS_TEMPLATE);
+        MOZ_ASSERT(anyChars.currentToken().type == TokenKind::TOK_TEMPLATE_HEAD ||
+                   anyChars.currentToken().type == TokenKind::TOK_NO_SUBS_TEMPLATE);
         const CharT* cur = userbuf.rawCharPtrAt(anyChars.currentToken().pos.begin + 1);
         const CharT* end;
-        if (anyChars.currentToken().type == TOK_TEMPLATE_HEAD) {
+        if (anyChars.currentToken().type == TokenKind::TOK_TEMPLATE_HEAD) {
             // Of the form    |`...${|   or   |}...${|
             end = userbuf.rawCharPtrAt(anyChars.currentToken().pos.end - 2);
         } else {
             // NO_SUBS_TEMPLATE is of the form   |`...`|   or   |}...`|
             end = userbuf.rawCharPtrAt(anyChars.currentToken().pos.end - 1);
         }
 
         CharBuffer charbuf(anyChars.cx);
@@ -1176,17 +1176,17 @@ class MOZ_STACK_CLASS TokenStreamSpecifi
     MOZ_MUST_USE bool getToken(TokenKind* ttp, Modifier modifier = None) {
         // Check for a pushed-back token resulting from mismatching lookahead.
         TokenStreamAnyChars& anyChars = anyCharsAccess();
         if (anyChars.lookahead != 0) {
             MOZ_ASSERT(!anyChars.flags.hadError);
             anyChars.lookahead--;
             anyChars.cursor = (anyChars.cursor + 1) & ntokensMask;
             TokenKind tt = anyChars.currentToken().type;
-            MOZ_ASSERT(tt != TOK_EOL);
+            MOZ_ASSERT(tt != TokenKind::TOK_EOL);
             verifyConsistentModifier(modifier, anyChars.currentToken());
             *ttp = tt;
             return true;
         }
 
         return getTokenInternal(ttp, modifier);
     }
 
@@ -1270,17 +1270,17 @@ class MOZ_STACK_CLASS TokenStreamSpecifi
         if (!getToken(&tmp, modifier))
             return false;
         const Token& next = anyChars.currentToken();
         anyChars.ungetToken();
 
         const auto& srcCoords = anyChars.srcCoords;
         *ttp = srcCoords.lineNum(curr.pos.end) == srcCoords.lineNum(next.pos.begin)
              ? next.type
-             : TOK_EOL;
+             : TokenKind::TOK_EOL;
         return true;
     }
 
     // Get the next token from the stream if its kind is |tt|.
     MOZ_MUST_USE bool matchToken(bool* matchedp, TokenKind tt, Modifier modifier = None) {
         TokenKind token;
         if (!getToken(&token, modifier))
             return false;
@@ -1300,17 +1300,17 @@ class MOZ_STACK_CLASS TokenStreamSpecifi
         MOZ_ALWAYS_TRUE(matched);
     }
 
     MOZ_MUST_USE bool nextTokenEndsExpr(bool* endsExpr) {
         TokenKind tt;
         if (!peekToken(&tt))
             return false;
 
-        *endsExpr = anyCharsAccess().isExprEnding[tt];
+        *endsExpr = anyCharsAccess().isExprEnding[size_t(tt)];
         if (*endsExpr) {
             // If the next token ends an overall Expression, we'll parse this
             // Expression without ever invoking Parser::orExpr().  But we need
             // that function's side effect of adding this modifier exception,
             // so we have to do it manually here.
             anyCharsAccess().addModifierException(OperandIsNone);
         }
         return true;
--- a/js/src/wasm/AsmJS.cpp
+++ b/js/src/wasm/AsmJS.cpp
@@ -761,46 +761,46 @@ NextNonEmptyStatement(ParseNode* pn)
 static bool
 GetToken(AsmJSParser& parser, TokenKind* tkp)
 {
     auto& ts = parser.tokenStream;
     TokenKind tk;
     while (true) {
         if (!ts.getToken(&tk, TokenStream::Operand))
             return false;
-        if (tk != TOK_SEMI)
+        if (tk != TokenKind::TOK_SEMI)
             break;
     }
     *tkp = tk;
     return true;
 }
 
 static bool
 PeekToken(AsmJSParser& parser, TokenKind* tkp)
 {
     auto& ts = parser.tokenStream;
     TokenKind tk;
     while (true) {
         if (!ts.peekToken(&tk, TokenStream::Operand))
             return false;
-        if (tk != TOK_SEMI)
+        if (tk != TokenKind::TOK_SEMI)
             break;
-        ts.consumeKnownToken(TOK_SEMI, TokenStream::Operand);
+        ts.consumeKnownToken(TokenKind::TOK_SEMI, TokenStream::Operand);
     }
     *tkp = tk;
     return true;
 }
 
 static bool
 ParseVarOrConstStatement(AsmJSParser& parser, ParseNode** var)
 {
     TokenKind tk;
     if (!PeekToken(parser, &tk))
         return false;
-    if (tk != TOK_VAR && tk != TOK_CONST) {
+    if (tk != TokenKind::TOK_VAR && tk != TokenKind::TOK_CONST) {
         *var = nullptr;
         return true;
     }
 
     *var = parser.statementListItem(YieldIsName);
     if (!*var)
         return false;
 
@@ -3843,28 +3843,28 @@ CheckModuleGlobal(ModuleValidator& m, Pa
 }
 
 static bool
 CheckModuleProcessingDirectives(ModuleValidator& m)
 {
     auto& ts = m.parser().tokenStream;
     while (true) {
         bool matched;
-        if (!ts.matchToken(&matched, TOK_STRING, TokenStream::Operand))
+        if (!ts.matchToken(&matched, TokenKind::TOK_STRING, TokenStream::Operand))
             return false;
         if (!matched)
             return true;
 
         if (!IsIgnoredDirectiveName(m.cx(), ts.anyCharsAccess().currentToken().atom()))
             return m.failCurrentOffset("unsupported processing directive");
 
         TokenKind tt;
         if (!ts.getToken(&tt))
             return false;
-        if (tt != TOK_SEMI)
+        if (tt != TokenKind::TOK_SEMI)
             return m.failCurrentOffset("expected semicolon after string literal");
     }
 }
 
 static bool
 CheckModuleGlobals(ModuleValidator& m)
 {
     while (true) {
@@ -7173,26 +7173,26 @@ CheckStatement(FunctionValidator& f, Par
     return f.fail(stmt, "unexpected statement kind");
 }
 
 static bool
 ParseFunction(ModuleValidator& m, ParseNode** fnOut, unsigned* line)
 {
     auto& tokenStream = m.tokenStream();
 
-    tokenStream.consumeKnownToken(TOK_FUNCTION, TokenStream::Operand);
+    tokenStream.consumeKnownToken(TokenKind::TOK_FUNCTION, TokenStream::Operand);
 
     auto& anyChars = tokenStream.anyCharsAccess();
     uint32_t toStringStart = anyChars.currentToken().pos.begin;
     *line = anyChars.srcCoords.lineNum(anyChars.currentToken().pos.end);
 
     TokenKind tk;
     if (!tokenStream.getToken(&tk, TokenStream::Operand))
         return false;
-    if (tk == TOK_MUL)
+    if (tk == TokenKind::TOK_MUL)
         return m.failCurrentOffset("unexpected generator function");
     if (!TokenKindIsPossibleIdentifier(tk))
         return false;  // The regular parser will throw a SyntaxError, no need to m.fail.
 
     RootedPropertyName name(m.cx(), m.parser().bindingIdentifier(YieldIsName));
     if (!name)
         return false;
 
@@ -7302,17 +7302,17 @@ CheckAllFunctionsDefined(ModuleValidator
 static bool
 CheckFunctions(ModuleValidator& m)
 {
     while (true) {
         TokenKind tk;
         if (!PeekToken(m.parser(), &tk))
             return false;
 
-        if (tk != TOK_FUNCTION)
+        if (tk != TokenKind::TOK_FUNCTION)
             break;
 
         if (!CheckFunction(m))
             return false;
     }
 
     return CheckAllFunctionsDefined(m);
 }
@@ -7436,18 +7436,18 @@ CheckModuleExportObject(ModuleValidator&
 
 static bool
 CheckModuleReturn(ModuleValidator& m)
 {
     TokenKind tk;
     if (!GetToken(m.parser(), &tk))
         return false;
     auto& ts = m.parser().tokenStream;
-    if (tk != TOK_RETURN) {
-        return m.failCurrentOffset((tk == TOK_RC || tk == TOK_EOF)
+    if (tk != TokenKind::TOK_RETURN) {
+        return m.failCurrentOffset((tk == TokenKind::TOK_RC || tk == TokenKind::TOK_EOF)
                                    ? "expecting return statement"
                                    : "invalid asm.js. statement");
     }
     ts.anyCharsAccess().ungetToken();
 
     ParseNode* returnStmt = m.parser().statementListItem(YieldIsName);
     if (!returnStmt)
         return false;
@@ -7469,17 +7469,17 @@ CheckModuleReturn(ModuleValidator& m)
 
 static bool
 CheckModuleEnd(ModuleValidator &m)
 {
     TokenKind tk;
     if (!GetToken(m.parser(), &tk))
         return false;
 
-    if (tk != TOK_EOF && tk != TOK_RC)
+    if (tk != TokenKind::TOK_EOF && tk != TokenKind::TOK_RC)
         return m.failCurrentOffset("top-level export (return) must be the last statement");
 
     m.parser().tokenStream.anyCharsAccess().ungetToken();
     return true;
 }
 
 static SharedModule
 CheckModule(JSContext* cx, AsmJSParser& parser, ParseNode* stmtList, unsigned* time)