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

Unified Diff: src/preparser.cc

Issue 156673002: Revert "Unify paren handling in Parser and PreParser." (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 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
« no previous file with comments | « src/preparser.h ('k') | test/cctest/test-parsing.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 becf9149fcf73c76a3c6a965c653efe029499116..4150d33a7af0c2d998608db050d9faaa436b673b 100644
--- a/src/preparser.cc
+++ b/src/preparser.cc
@@ -168,18 +168,15 @@ PreParser::SourceElements PreParser::ParseSourceElements(int end_token,
// SourceElements ::
// (Statement)* <end_token>
- bool directive_prologue = true;
+ bool allow_directive_prologue = true;
while (peek() != end_token) {
- if (directive_prologue && peek() != Token::STRING) {
- directive_prologue = false;
- }
Statement statement = ParseSourceElement(CHECK_OK);
- if (directive_prologue) {
+ if (allow_directive_prologue) {
if (statement.IsUseStrictLiteral()) {
set_language_mode(allow_harmony_scoping() ?
EXTENDED_MODE : STRICT_MODE);
} else if (!statement.IsStringLiteral()) {
- directive_prologue = false;
+ allow_directive_prologue = false;
}
}
}
@@ -471,20 +468,16 @@ PreParser::Statement PreParser::ParseExpressionOrLabelledStatement(bool* ok) {
// Expression ';'
// Identifier ':' Statement
- bool starts_with_identifier = peek_any_identifier();
Expression expr = ParseExpression(true, CHECK_OK);
- // Even if the expression starts with an identifier, it is not necessarily an
- // identifier. For example, "foo + bar" starts with an identifier but is not
- // an identifier.
- if (peek() == Token::COLON && starts_with_identifier && expr.IsIdentifier()) {
- // Expression is a single identifier, and not, e.g., a parenthesized
- // identifier.
+ if (expr.IsRawIdentifier()) {
ASSERT(!expr.AsIdentifier().IsFutureReserved());
ASSERT(is_classic_mode() ||
(!expr.AsIdentifier().IsFutureStrictReserved() &&
!expr.AsIdentifier().IsYield()));
- Consume(Token::COLON);
- return ParseStatement(ok);
+ if (peek() == Token::COLON) {
+ Consume(Token::COLON);
+ return ParseStatement(ok);
+ }
// Preparsing is disabled for extensions (because the extension details
// aren't passed to lazily compiled functions), so we don't
// accept "native function" in the preparser.
@@ -1177,6 +1170,7 @@ PreParser::Expression PreParser::ParsePrimaryExpression(bool* ok) {
parenthesized_function_ = (peek() == Token::FUNCTION);
result = ParseExpression(true, CHECK_OK);
Expect(Token::RPAREN, CHECK_OK);
+ result = result.Parenthesize();
break;
case Token::MOD:
« no previous file with comments | « src/preparser.h ('k') | test/cctest/test-parsing.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698