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