Commit 8a809a9c authored by arv's avatar arv Committed by Commit bot

Rename ParseSourceElements in preparser too

BUG=None
R=adamk
LOG=N

Review URL: https://codereview.chromium.org/905003003

Cr-Commit-Position: refs/heads/master@{#26498}
parent 64abe652
...@@ -2077,7 +2077,7 @@ Block* Parser::ParseScopedBlock(ZoneList<const AstRawString*>* labels, ...@@ -2077,7 +2077,7 @@ Block* Parser::ParseScopedBlock(ZoneList<const AstRawString*>* labels,
// The harmony mode uses block elements instead of statements. // The harmony mode uses block elements instead of statements.
// //
// Block :: // Block ::
// '{' BlockElement* '}' // '{' StatementList '}'
// Construct block expecting 16 statements. // Construct block expecting 16 statements.
Block* body = Block* body =
......
...@@ -156,14 +156,7 @@ PreParserExpression PreParserTraits::ParseClassLiteral( ...@@ -156,14 +156,7 @@ PreParserExpression PreParserTraits::ParseClassLiteral(
// it is used) are generally omitted. // it is used) are generally omitted.
#define CHECK_OK ok); \ PreParser::Statement PreParser::ParseStatementListItem(bool* ok) {
if (!*ok) return kUnknownSourceElements; \
((void)0
#define DUMMY ) // to make indentation work
#undef DUMMY
PreParser::Statement PreParser::ParseSourceElement(bool* ok) {
// ECMA 262 6th Edition // ECMA 262 6th Edition
// StatementListItem[Yield, Return] : // StatementListItem[Yield, Return] :
// Statement[?Yield, ?Return] // Statement[?Yield, ?Return]
...@@ -200,8 +193,7 @@ PreParser::Statement PreParser::ParseSourceElement(bool* ok) { ...@@ -200,8 +193,7 @@ PreParser::Statement PreParser::ParseSourceElement(bool* ok) {
} }
PreParser::SourceElements PreParser::ParseSourceElements(int end_token, void PreParser::ParseStatementList(int end_token, bool* ok) {
bool* ok) {
// SourceElements :: // SourceElements ::
// (Statement)* <end_token> // (Statement)* <end_token>
...@@ -210,7 +202,8 @@ PreParser::SourceElements PreParser::ParseSourceElements(int end_token, ...@@ -210,7 +202,8 @@ PreParser::SourceElements PreParser::ParseSourceElements(int end_token,
if (directive_prologue && peek() != Token::STRING) { if (directive_prologue && peek() != Token::STRING) {
directive_prologue = false; directive_prologue = false;
} }
Statement statement = ParseSourceElement(CHECK_OK); Statement statement = ParseStatementListItem(ok);
if (!*ok) return;
if (directive_prologue) { if (directive_prologue) {
if (statement.IsUseStrictLiteral()) { if (statement.IsUseStrictLiteral()) {
scope_->SetLanguageMode( scope_->SetLanguageMode(
...@@ -223,11 +216,9 @@ PreParser::SourceElements PreParser::ParseSourceElements(int end_token, ...@@ -223,11 +216,9 @@ PreParser::SourceElements PreParser::ParseSourceElements(int end_token,
} }
} }
} }
return kUnknownSourceElements;
} }
#undef CHECK_OK
#define CHECK_OK ok); \ #define CHECK_OK ok); \
if (!*ok) return Statement::Default(); \ if (!*ok) return Statement::Default(); \
((void)0 ((void)0
...@@ -387,7 +378,7 @@ PreParser::Statement PreParser::ParseBlock(bool* ok) { ...@@ -387,7 +378,7 @@ PreParser::Statement PreParser::ParseBlock(bool* ok) {
Expect(Token::LBRACE, CHECK_OK); Expect(Token::LBRACE, CHECK_OK);
while (peek() != Token::RBRACE) { while (peek() != Token::RBRACE) {
if (allow_harmony_scoping() && is_strict(language_mode())) { if (allow_harmony_scoping() && is_strict(language_mode())) {
ParseSourceElement(CHECK_OK); ParseStatementListItem(CHECK_OK);
} else { } else {
ParseStatement(CHECK_OK); ParseStatement(CHECK_OK);
} }
...@@ -932,7 +923,7 @@ PreParser::Expression PreParser::ParseFunctionLiteral( ...@@ -932,7 +923,7 @@ PreParser::Expression PreParser::ParseFunctionLiteral(
if (is_lazily_parsed) { if (is_lazily_parsed) {
ParseLazyFunctionLiteralBody(CHECK_OK); ParseLazyFunctionLiteralBody(CHECK_OK);
} else { } else {
ParseSourceElements(Token::RBRACE, ok); ParseStatementList(Token::RBRACE, CHECK_OK);
} }
Expect(Token::RBRACE, CHECK_OK); Expect(Token::RBRACE, CHECK_OK);
...@@ -956,7 +947,7 @@ PreParser::Expression PreParser::ParseFunctionLiteral( ...@@ -956,7 +947,7 @@ PreParser::Expression PreParser::ParseFunctionLiteral(
void PreParser::ParseLazyFunctionLiteralBody(bool* ok) { void PreParser::ParseLazyFunctionLiteralBody(bool* ok) {
int body_start = position(); int body_start = position();
ParseSourceElements(Token::RBRACE, ok); ParseStatementList(Token::RBRACE, ok);
if (!*ok) return; if (!*ok) return;
// Position right after terminal '}'. // Position right after terminal '}'.
......
...@@ -1564,7 +1564,7 @@ class PreParser : public ParserBase<PreParserTraits> { ...@@ -1564,7 +1564,7 @@ class PreParser : public ParserBase<PreParserTraits> {
&factory); &factory);
bool ok = true; bool ok = true;
int start_position = scanner()->peek_location().beg_pos; int start_position = scanner()->peek_location().beg_pos;
ParseSourceElements(Token::EOS, &ok); ParseStatementList(Token::EOS, &ok);
if (stack_overflow()) return kPreParseStackOverflow; if (stack_overflow()) return kPreParseStackOverflow;
if (!ok) { if (!ok) {
ReportUnexpectedToken(scanner()->current_token()); ReportUnexpectedToken(scanner()->current_token());
...@@ -1609,17 +1609,12 @@ class PreParser : public ParserBase<PreParserTraits> { ...@@ -1609,17 +1609,12 @@ class PreParser : public ParserBase<PreParserTraits> {
kHasNoInitializers kHasNoInitializers
}; };
enum SourceElements {
kUnknownSourceElements
};
// All ParseXXX functions take as the last argument an *ok parameter // All ParseXXX functions take as the last argument an *ok parameter
// which is set to false if parsing failed; it is unchanged otherwise. // which is set to false if parsing failed; it is unchanged otherwise.
// By making the 'exception handling' explicit, we are forced to check // By making the 'exception handling' explicit, we are forced to check
// for failure at the call sites. // for failure at the call sites.
Statement ParseSourceElement(bool* ok); Statement ParseStatementListItem(bool* ok);
SourceElements ParseSourceElements(int end_token, bool* ok); void ParseStatementList(int end_token, bool* ok);
Statement ParseStatement(bool* ok); Statement ParseStatement(bool* ok);
Statement ParseFunctionDeclaration(bool* ok); Statement ParseFunctionDeclaration(bool* ok);
Statement ParseClassDeclaration(bool* ok); Statement ParseClassDeclaration(bool* ok);
...@@ -1682,7 +1677,7 @@ PreParserStatementList PreParser::ParseEagerFunctionBody( ...@@ -1682,7 +1677,7 @@ PreParserStatementList PreParser::ParseEagerFunctionBody(
Token::Value fvar_init_op, FunctionKind kind, bool* ok) { Token::Value fvar_init_op, FunctionKind kind, bool* ok) {
ParsingModeScope parsing_mode(this, PARSE_EAGERLY); ParsingModeScope parsing_mode(this, PARSE_EAGERLY);
ParseSourceElements(Token::RBRACE, ok); ParseStatementList(Token::RBRACE, ok);
if (!*ok) return PreParserStatementList(); if (!*ok) return PreParserStatementList();
Expect(Token::RBRACE, ok); Expect(Token::RBRACE, ok);
......
...@@ -292,7 +292,7 @@ CheckStrictMode("const x = 0;", SyntaxError); ...@@ -292,7 +292,7 @@ CheckStrictMode("const x = 0;", SyntaxError);
CheckStrictMode("for (const x = 0; false;) {}", SyntaxError); CheckStrictMode("for (const x = 0; false;) {}", SyntaxError);
CheckStrictMode("function strict() { const x = 0; }", SyntaxError); CheckStrictMode("function strict() { const x = 0; }", SyntaxError);
// Strict mode only allows functions in SourceElements // Strict mode only allows functions in StatementList
CheckStrictMode("if (true) { function invalid() {} }", SyntaxError); CheckStrictMode("if (true) { function invalid() {} }", SyntaxError);
CheckStrictMode("for (;false;) { function invalid() {} }", SyntaxError); CheckStrictMode("for (;false;) { function invalid() {} }", SyntaxError);
CheckStrictMode("{ function invalid() {} }", SyntaxError); CheckStrictMode("{ function invalid() {} }", SyntaxError);
......
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