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

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: Relax assertion criteria Created 4 years, 8 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 fae9ea8bffb7f07feff5fe25fd851a79631e7a38..12d7103640a9bf5083ac5adec762f9e79a381206 100644
--- a/src/parsing/token.h
+++ b/src/parsing/token.h
@@ -148,10 +148,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) \
@@ -173,7 +175,6 @@ namespace internal {
T(TEMPLATE_SPAN, NULL, 0) \
T(TEMPLATE_TAIL, NULL, 0)
-
class Token {
public:
// All token values.
@@ -197,7 +198,7 @@ class Token {
}
static bool IsIdentifier(Value tok, LanguageMode language_mode,
- bool is_generator) {
+ bool is_generator, bool is_module) {
switch (tok) {
case IDENTIFIER:
return true;
@@ -208,6 +209,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;
}
« no previous file with comments | « src/parsing/scanner.cc ('k') | test/cctest/test-parsing.cc » ('j') | test/cctest/test-parsing.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698