Commit 660514b0 authored by Toon Verwaest's avatar Toon Verwaest Committed by Commit Bot

[parser] Consume rather than Expect start of array/object literal

Change-Id: I07a95f70b32a065233df61110add3c71b85ec025
Reviewed-on: https://chromium-review.googlesource.com/1193895Reviewed-by: 's avatarIgor Sheludko <ishell@chromium.org>
Commit-Queue: Toon Verwaest <verwaest@chromium.org>
Cr-Commit-Position: refs/heads/master@{#55504}
parent 6206a3e3
...@@ -719,7 +719,7 @@ class ParserBase { ...@@ -719,7 +719,7 @@ class ParserBase {
Token::Value next = Next(); Token::Value next = Next();
USE(next); USE(next);
USE(token); USE(token);
DCHECK(next == token); DCHECK_EQ(next, token);
} }
bool Check(Token::Value token) { bool Check(Token::Value token) {
...@@ -2080,7 +2080,7 @@ typename ParserBase<Impl>::ExpressionT ParserBase<Impl>::ParseArrayLiteral( ...@@ -2080,7 +2080,7 @@ typename ParserBase<Impl>::ExpressionT ParserBase<Impl>::ParseArrayLiteral(
int pos = peek_position(); int pos = peek_position();
ExpressionListT values = impl()->NewExpressionList(4); ExpressionListT values = impl()->NewExpressionList(4);
int first_spread_index = -1; int first_spread_index = -1;
Expect(Token::LBRACK, CHECK_OK); Consume(Token::LBRACK);
while (peek() != Token::RBRACK) { while (peek() != Token::RBRACK) {
ExpressionT elem; ExpressionT elem;
if (peek() == Token::COMMA) { if (peek() == Token::COMMA) {
...@@ -2543,7 +2543,7 @@ ParserBase<Impl>::ParseObjectPropertyDefinition(ObjectLiteralChecker* checker, ...@@ -2543,7 +2543,7 @@ ParserBase<Impl>::ParseObjectPropertyDefinition(ObjectLiteralChecker* checker,
case PropertyKind::kSpreadProperty: case PropertyKind::kSpreadProperty:
DCHECK(!is_get && !is_set && !is_generator && !is_async && DCHECK(!is_get && !is_set && !is_generator && !is_async &&
!*is_computed_name); !*is_computed_name);
DCHECK(name_token == Token::ELLIPSIS); DCHECK_EQ(Token::ELLIPSIS, name_token);
*is_computed_name = true; *is_computed_name = true;
*is_rest_property = true; *is_rest_property = true;
...@@ -2726,7 +2726,7 @@ typename ParserBase<Impl>::ExpressionT ParserBase<Impl>::ParseObjectLiteral( ...@@ -2726,7 +2726,7 @@ typename ParserBase<Impl>::ExpressionT ParserBase<Impl>::ParseObjectLiteral(
bool has_rest_property = false; bool has_rest_property = false;
ObjectLiteralChecker checker(this); ObjectLiteralChecker checker(this);
Expect(Token::LBRACE, CHECK_OK); Consume(Token::LBRACE);
while (peek() != Token::RBRACE) { while (peek() != Token::RBRACE) {
FuncNameInferrer::State fni_state(fni_); FuncNameInferrer::State fni_state(fni_);
...@@ -4298,7 +4298,7 @@ void ParserBase<Impl>::CheckArityRestrictions(int param_count, ...@@ -4298,7 +4298,7 @@ void ParserBase<Impl>::CheckArityRestrictions(int param_count,
template <typename Impl> template <typename Impl>
bool ParserBase<Impl>::IsNextLetKeyword() { bool ParserBase<Impl>::IsNextLetKeyword() {
DCHECK(peek() == Token::LET); DCHECK_EQ(Token::LET, peek());
Token::Value next_next = PeekAhead(); Token::Value next_next = PeekAhead();
switch (next_next) { switch (next_next) {
case Token::LBRACE: case Token::LBRACE:
...@@ -5839,7 +5839,7 @@ ParserBase<Impl>::ParseForEachStatementWithDeclarations( ...@@ -5839,7 +5839,7 @@ ParserBase<Impl>::ParseForEachStatementWithDeclarations(
Scope* for_scope = nullptr; Scope* for_scope = nullptr;
if (inner_block_scope != nullptr) { if (inner_block_scope != nullptr) {
for_scope = inner_block_scope->outer_scope(); for_scope = inner_block_scope->outer_scope();
DCHECK(for_scope == scope()); DCHECK_EQ(for_scope, scope());
inner_block_scope->set_start_position(scanner()->location().beg_pos); inner_block_scope->set_start_position(scanner()->location().beg_pos);
} }
......
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