Commit 3cdb812c authored by Toon Verwaest's avatar Toon Verwaest Committed by Commit Bot

[parser] Reuse expression classifier across conditional lhs/rhs

Change-Id: Ibf0ee76cc19799be405f45bcba7a1d3a7c5c4d38
Reviewed-on: https://chromium-review.googlesource.com/c/1288390
Commit-Queue: Toon Verwaest <verwaest@chromium.org>
Reviewed-by: 's avatarAdam Klein <adamk@chromium.org>
Cr-Commit-Position: refs/heads/master@{#56786}
parent 6392442e
...@@ -2966,27 +2966,26 @@ ParserBase<Impl>::ParseConditionalContinuation(ExpressionT expression, ...@@ -2966,27 +2966,26 @@ ParserBase<Impl>::ParseConditionalContinuation(ExpressionT expression,
BindingPatternUnexpectedToken(); BindingPatternUnexpectedToken();
ArrowFormalParametersUnexpectedToken(); ArrowFormalParametersUnexpectedToken();
ExpressionClassifier classifier(this);
ExpressionT left; ExpressionT left;
{ {
SourceRangeScope range_scope(scanner(), &then_range); SourceRangeScope range_scope(scanner(), &then_range);
Consume(Token::CONDITIONAL); Consume(Token::CONDITIONAL);
ExpressionClassifier classifier(this);
// In parsing the first assignment expression in conditional // In parsing the first assignment expression in conditional
// expressions we always accept the 'in' keyword; see ECMA-262, // expressions we always accept the 'in' keyword; see ECMA-262,
// section 11.12, page 58. // section 11.12, page 58.
left = ParseAssignmentExpression(true, CHECK_OK); left = ParseAssignmentExpression(true, CHECK_OK);
AccumulateNonBindingPatternErrors();
} }
ExpressionT right; ExpressionT right;
{ {
SourceRangeScope range_scope(scanner(), &else_range); SourceRangeScope range_scope(scanner(), &else_range);
Expect(Token::COLON, CHECK_OK); Expect(Token::COLON, CHECK_OK);
ExpressionClassifier classifier(this);
right = ParseAssignmentExpression(accept_IN, CHECK_OK); right = ParseAssignmentExpression(accept_IN, CHECK_OK);
AccumulateNonBindingPatternErrors();
} }
ExpressionT expr = factory()->NewConditional(expression, left, right, pos); ExpressionT expr = factory()->NewConditional(expression, left, right, pos);
impl()->RecordConditionalSourceRange(expr, then_range, else_range); impl()->RecordConditionalSourceRange(expr, then_range, else_range);
AccumulateNonBindingPatternErrors();
return expr; return expr;
} }
......
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