Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(981)

Unified Diff: src/parsing/token.h

Issue 1723313002: [parser] Enforce module-specific identifier restriction (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/parsing/token.h
diff --git a/src/parsing/token.h b/src/parsing/token.h
index 7a62b4d9153a399ac546df9496ed5d921d863ed3..f52881b337f81e73b8de10bf4b52bdd85d98950b 100644
--- a/src/parsing/token.h
+++ b/src/parsing/token.h
@@ -146,10 +146,12 @@ namespace internal {
T(IDENTIFIER, NULL, 0) \
\
/* Future reserved words (ECMA-262, section 7.6.1.2). */ \
- T(FUTURE_RESERVED_WORD, NULL, 0) \
T(FUTURE_STRICT_RESERVED_WORD, NULL, 0) \
+ /* `await` is a reserved word in module code only */ \
+ K(AWAIT, "await", 0) \
K(CLASS, "class", 0) \
K(CONST, "const", 0) \
+ K(ENUM, "enum", 0) \
K(EXPORT, "export", 0) \
K(EXTENDS, "extends", 0) \
K(IMPORT, "import", 0) \
@@ -171,7 +173,6 @@ namespace internal {
T(TEMPLATE_SPAN, NULL, 0) \
T(TEMPLATE_TAIL, NULL, 0)
-
class Token {
public:
// All token values.
@@ -195,7 +196,7 @@ class Token {
}
static bool IsIdentifier(Value tok, LanguageMode language_mode,
- bool is_generator) {
+ bool is_generator, bool is_module) {
mike3 2016/02/23 19:29:44 This method is starting to succumb to the boolean
switch (tok) {
case IDENTIFIER:
return true;
@@ -206,6 +207,8 @@ class Token {
return is_sloppy(language_mode);
case YIELD:
return !is_generator && is_sloppy(language_mode);
+ case AWAIT:
+ return !is_module;
default:
return false;
}

Powered by Google App Engine
This is Rietveld 408576698