Index: src/preparser.cc |
diff --git a/src/preparser.cc b/src/preparser.cc |
index 21da4f80d418cb31d6d9e1c8bdbd4e3972d6be5e..ad162ed2666b1274277cdec1f6666537cc178f36 100644 |
--- a/src/preparser.cc |
+++ b/src/preparser.cc |
@@ -1119,6 +1119,16 @@ PreParser::Expression PreParser::ParsePrimaryExpression(bool* ok) { |
return Expression::Default(); |
} |
+ // FIXME!!!! |
+ case i::Token::YIELD: |
wingo
2013/03/11 12:10:53
This FIXME is to mark that this case and the FUTUR
|
+ if (scope_->is_generator()) { |
+ // 'yield' in a generator is only valid as part of a YieldExpression. |
+ i::Scanner::Location location = scanner_->location(); |
+ ReportMessageAt(location, "unexpected_token", NULL); |
+ *ok = false; |
+ return Expression::Default(); |
+ } |
+ // FALLTHROUGH |
case i::Token::FUTURE_STRICT_RESERVED_WORD: |
if (!is_classic_mode()) { |
Next(); |
@@ -1513,6 +1523,8 @@ PreParser::Identifier PreParser::GetIdentifierSymbol() { |
} else if (scanner_->current_token() == |
i::Token::FUTURE_STRICT_RESERVED_WORD) { |
return Identifier::FutureStrictReserved(); |
+ } else if (scanner_->current_token() == i::Token::YIELD) { |
+ return Identifier::Yield(); |
} |
if (scanner_->is_literal_ascii()) { |
// Detect strict-mode poison words. |
@@ -1539,6 +1551,16 @@ PreParser::Identifier PreParser::ParseIdentifier(bool* ok) { |
*ok = false; |
return GetIdentifierSymbol(); |
} |
+ case i::Token::YIELD: |
+ if (scope_->is_generator()) { |
+ // 'yield' in a generator is only valid as part of a YieldExpression. |
+ i::Scanner::Location location = scanner_->location(); |
+ ReportMessageAt(location.beg_pos, location.end_pos, |
+ "unexpected_token", NULL); |
+ *ok = false; |
+ return Identifier::Default(); |
+ } |
+ // FALLTHROUGH |
case i::Token::FUTURE_STRICT_RESERVED_WORD: |
if (!is_classic_mode()) { |
i::Scanner::Location location = scanner_->location(); |
@@ -1596,7 +1618,7 @@ void PreParser::StrictModeIdentifierViolation(i::Scanner::Location location, |
const char* type = eval_args_type; |
if (identifier.IsFutureReserved()) { |
type = "reserved_word"; |
- } else if (identifier.IsFutureStrictReserved()) { |
+ } else if (identifier.IsFutureStrictReserved() || identifier.IsYield()) { |
type = "strict_reserved_word"; |
} |
if (!is_classic_mode()) { |