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

Unified Diff: src/preparser.cc

Issue 12646003: Add parser support for generators. (Closed) Base URL: git://github.com/v8/v8.git@bleeding_edge
Patch Set: Created 7 years, 9 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
« no previous file with comments | « src/preparser.h ('k') | src/scanner.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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()) {
« no previous file with comments | « src/preparser.h ('k') | src/scanner.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698