OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef V8_PARSING_PARSER_BASE_H | 5 #ifndef V8_PARSING_PARSER_BASE_H |
6 #define V8_PARSING_PARSER_BASE_H | 6 #define V8_PARSING_PARSER_BASE_H |
7 | 7 |
8 #include "src/ast/ast.h" | 8 #include "src/ast/ast.h" |
9 #include "src/ast/scopes.h" | 9 #include "src/ast/scopes.h" |
10 #include "src/bailout-reason.h" | 10 #include "src/bailout-reason.h" |
(...skipping 1752 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1763 /* falls through */ | 1763 /* falls through */ |
1764 case Token::IDENTIFIER: | 1764 case Token::IDENTIFIER: |
1765 case Token::LET: | 1765 case Token::LET: |
1766 case Token::STATIC: | 1766 case Token::STATIC: |
1767 case Token::YIELD: | 1767 case Token::YIELD: |
1768 case Token::AWAIT: | 1768 case Token::AWAIT: |
1769 case Token::ESCAPED_STRICT_RESERVED_WORD: | 1769 case Token::ESCAPED_STRICT_RESERVED_WORD: |
1770 case Token::FUTURE_STRICT_RESERVED_WORD: { | 1770 case Token::FUTURE_STRICT_RESERVED_WORD: { |
1771 // Using eval or arguments in this context is OK even in strict mode. | 1771 // Using eval or arguments in this context is OK even in strict mode. |
1772 IdentifierT name = ParseAndClassifyIdentifier(CHECK_OK); | 1772 IdentifierT name = ParseAndClassifyIdentifier(CHECK_OK); |
1773 return impl()->ExpressionFromIdentifier(name, beg_pos, | 1773 return impl()->ExpressionFromIdentifier(name, beg_pos); |
1774 scanner()->location().end_pos); | |
1775 } | 1774 } |
1776 | 1775 |
1777 case Token::STRING: { | 1776 case Token::STRING: { |
1778 BindingPatternUnexpectedToken(); | 1777 BindingPatternUnexpectedToken(); |
1779 Consume(Token::STRING); | 1778 Consume(Token::STRING); |
1780 return impl()->ExpressionFromString(beg_pos); | 1779 return impl()->ExpressionFromString(beg_pos); |
1781 } | 1780 } |
1782 | 1781 |
1783 case Token::ASSIGN_DIV: | 1782 case Token::ASSIGN_DIV: |
1784 case Token::DIV: | 1783 case Token::DIV: |
(...skipping 600 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2385 if (name_token == Token::LET) { | 2384 if (name_token == Token::LET) { |
2386 classifier()->RecordLetPatternError( | 2385 classifier()->RecordLetPatternError( |
2387 scanner()->location(), MessageTemplate::kLetInLexicalBinding); | 2386 scanner()->location(), MessageTemplate::kLetInLexicalBinding); |
2388 } | 2387 } |
2389 if (name_token == Token::AWAIT) { | 2388 if (name_token == Token::AWAIT) { |
2390 DCHECK(!is_async_function()); | 2389 DCHECK(!is_async_function()); |
2391 classifier()->RecordAsyncArrowFormalParametersError( | 2390 classifier()->RecordAsyncArrowFormalParametersError( |
2392 Scanner::Location(next_beg_pos, next_end_pos), | 2391 Scanner::Location(next_beg_pos, next_end_pos), |
2393 MessageTemplate::kAwaitBindingIdentifier); | 2392 MessageTemplate::kAwaitBindingIdentifier); |
2394 } | 2393 } |
2395 ExpressionT lhs = | 2394 ExpressionT lhs = impl()->ExpressionFromIdentifier(name, next_beg_pos); |
2396 impl()->ExpressionFromIdentifier(name, next_beg_pos, next_end_pos); | |
2397 CheckDestructuringElement(lhs, next_beg_pos, next_end_pos); | 2395 CheckDestructuringElement(lhs, next_beg_pos, next_end_pos); |
2398 | 2396 |
2399 ExpressionT value; | 2397 ExpressionT value; |
2400 if (peek() == Token::ASSIGN) { | 2398 if (peek() == Token::ASSIGN) { |
2401 Consume(Token::ASSIGN); | 2399 Consume(Token::ASSIGN); |
2402 ExpressionClassifier rhs_classifier(this); | 2400 ExpressionClassifier rhs_classifier(this); |
2403 ExpressionT rhs = ParseAssignmentExpression( | 2401 ExpressionT rhs = ParseAssignmentExpression( |
2404 true, CHECK_OK_CUSTOM(EmptyObjectLiteralProperty)); | 2402 true, CHECK_OK_CUSTOM(EmptyObjectLiteralProperty)); |
2405 impl()->RewriteNonPattern(CHECK_OK_CUSTOM(EmptyObjectLiteralProperty)); | 2403 impl()->RewriteNonPattern(CHECK_OK_CUSTOM(EmptyObjectLiteralProperty)); |
2406 impl()->AccumulateFormalParameterContainmentErrors(); | 2404 impl()->AccumulateFormalParameterContainmentErrors(); |
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2653 if (IsTrivialExpression()) { | 2651 if (IsTrivialExpression()) { |
2654 expression = ParsePrimaryExpression(&is_async, CHECK_OK); | 2652 expression = ParsePrimaryExpression(&is_async, CHECK_OK); |
2655 } else { | 2653 } else { |
2656 expression = ParseConditionalExpression(accept_IN, CHECK_OK); | 2654 expression = ParseConditionalExpression(accept_IN, CHECK_OK); |
2657 } | 2655 } |
2658 | 2656 |
2659 if (is_async && impl()->IsIdentifier(expression) && peek_any_identifier() && | 2657 if (is_async && impl()->IsIdentifier(expression) && peek_any_identifier() && |
2660 PeekAhead() == Token::ARROW) { | 2658 PeekAhead() == Token::ARROW) { |
2661 // async Identifier => AsyncConciseBody | 2659 // async Identifier => AsyncConciseBody |
2662 IdentifierT name = ParseAndClassifyIdentifier(CHECK_OK); | 2660 IdentifierT name = ParseAndClassifyIdentifier(CHECK_OK); |
2663 expression = impl()->ExpressionFromIdentifier( | 2661 expression = |
2664 name, position(), scanner()->location().end_pos, InferName::kNo); | 2662 impl()->ExpressionFromIdentifier(name, position(), InferName::kNo); |
2665 if (fni_) { | 2663 if (fni_) { |
2666 // Remove `async` keyword from inferred name stack. | 2664 // Remove `async` keyword from inferred name stack. |
2667 fni_->RemoveAsyncKeywordFromEnd(); | 2665 fni_->RemoveAsyncKeywordFromEnd(); |
2668 } | 2666 } |
2669 } | 2667 } |
2670 | 2668 |
2671 if (peek() == Token::ARROW) { | 2669 if (peek() == Token::ARROW) { |
2672 Scanner::Location arrow_loc = scanner()->peek_location(); | 2670 Scanner::Location arrow_loc = scanner()->peek_location(); |
2673 ValidateArrowFormalParameters(expression, parenthesized_formals, is_async, | 2671 ValidateArrowFormalParameters(expression, parenthesized_formals, is_async, |
2674 CHECK_OK); | 2672 CHECK_OK); |
(...skipping 2788 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5463 has_seen_constructor_ = true; | 5461 has_seen_constructor_ = true; |
5464 return; | 5462 return; |
5465 } | 5463 } |
5466 } | 5464 } |
5467 | 5465 |
5468 | 5466 |
5469 } // namespace internal | 5467 } // namespace internal |
5470 } // namespace v8 | 5468 } // namespace v8 |
5471 | 5469 |
5472 #endif // V8_PARSING_PARSER_BASE_H | 5470 #endif // V8_PARSING_PARSER_BASE_H |
OLD | NEW |