Commit 9af251df authored by Toon Verwaest's avatar Toon Verwaest Committed by Commit Bot

[parser] Drop eval and arguments as contextual keywords

We're fetching the symbols anyway, so we might as well use those instead in the
preparser.

Change-Id: Ie937c755690cdd7b15e8486aa9680d530eff602e
Reviewed-on: https://chromium-review.googlesource.com/c/1332296Reviewed-by: 's avatarSathya Gunasekaran <gsathya@chromium.org>
Reviewed-by: 's avatarIgor Sheludko <ishell@chromium.org>
Commit-Queue: Toon Verwaest <verwaest@chromium.org>
Cr-Commit-Position: refs/heads/master@{#57460}
parent 04af85c6
......@@ -20,7 +20,9 @@ namespace internal {
namespace {
PreParserIdentifier GetSymbolHelper(Scanner* scanner) {
PreParserIdentifier GetSymbolHelper(Scanner* scanner,
const AstRawString* string,
AstValueFactory* avf) {
// These symbols require slightly different treatement:
// - regular keywords (async, await, etc.; treated in 1st switch.)
// - 'contextual' keywords (and may contain escaped; treated in 2nd switch.)
......@@ -46,13 +48,11 @@ PreParserIdentifier GetSymbolHelper(Scanner* scanner) {
if (scanner->literal_contains_escapes()) {
return PreParserIdentifier::Default();
}
switch (scanner->current_contextual_token()) {
case Token::EVAL:
return PreParserIdentifier::Eval();
case Token::ARGUMENTS:
return PreParserIdentifier::Arguments();
default:
break;
if (string == avf->eval_string()) {
return PreParserIdentifier::Eval();
}
if (string == avf->arguments_string()) {
return PreParserIdentifier::Arguments();
}
return PreParserIdentifier::Default();
}
......@@ -60,8 +60,9 @@ PreParserIdentifier GetSymbolHelper(Scanner* scanner) {
} // unnamed namespace
PreParserIdentifier PreParser::GetSymbol() const {
PreParserIdentifier symbol = GetSymbolHelper(scanner());
const AstRawString* result = scanner()->CurrentSymbol(ast_value_factory());
PreParserIdentifier symbol =
GetSymbolHelper(scanner(), result, ast_value_factory());
DCHECK_NOT_NULL(result);
symbol.string_ = result;
return symbol;
......
......@@ -154,7 +154,6 @@ static const Token::Value one_char_tokens[] = {
#define KEYWORDS(KEYWORD_GROUP, KEYWORD) \
KEYWORD_GROUP('a') \
KEYWORD("arguments", Token::ARGUMENTS) \
KEYWORD("as", Token::AS) \
KEYWORD("async", Token::ASYNC) \
KEYWORD("await", Token::AWAIT) \
......@@ -176,7 +175,6 @@ static const Token::Value one_char_tokens[] = {
KEYWORD_GROUP('e') \
KEYWORD("else", Token::ELSE) \
KEYWORD("enum", Token::ENUM) \
KEYWORD("eval", Token::EVAL) \
KEYWORD("export", Token::EXPORT) \
KEYWORD("extends", Token::EXTENDS) \
KEYWORD_GROUP('f') \
......
......@@ -207,8 +207,6 @@ namespace internal {
C(CONSTRUCTOR, "constructor", 0) \
C(PRIVATE_CONSTRUCTOR, "#constructor", 0) \
C(PROTOTYPE, "prototype", 0) \
C(EVAL, "eval", 0) \
C(ARGUMENTS, "arguments", 0) \
C(UNDEFINED, "undefined", 0) \
C(ANONYMOUS, "anonymous", 0)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment