Reorganize token types and use a map for them (#9645)

This commit is contained in:
Daniel Tschinder
2019-03-06 14:30:04 -08:00
committed by GitHub
parent e53be4b387
commit d8a5329834
4 changed files with 63 additions and 108 deletions

View File

@@ -3,6 +3,7 @@
// @flow
import * as charCodes from "charcodes";
import { keywords } from "../tokenizer/types";
const reservedWords = {
strict: [
@@ -52,44 +53,6 @@ export function isStrictBindReservedWord(
return isReservedWord(word, inModule) || reservedWordsStrictBindSet.has(word);
}
const keywords = new Set([
"break",
"case",
"catch",
"continue",
"debugger",
"default",
"do",
"else",
"finally",
"for",
"function",
"if",
"return",
"switch",
"throw",
"try",
"var",
"while",
"with",
"null",
"true",
"false",
"instanceof",
"typeof",
"void",
"delete",
"new",
"in",
"this",
"const",
"class",
"extends",
"export",
"import",
"super",
]);
export function isKeyword(word: string): boolean {
return keywords.has(word);
}