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 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
243 enum LazyParsingResult { | 243 enum LazyParsingResult { |
244 kLazyParsingComplete, | 244 kLazyParsingComplete, |
245 kLazyParsingAborted | 245 kLazyParsingAborted |
246 }; | 246 }; |
247 | 247 |
248 enum VariableDeclarationContext { | 248 enum VariableDeclarationContext { |
249 kStatementListItem, | 249 kStatementListItem, |
250 kStatement, | 250 kStatement, |
251 kForStatement | 251 kForStatement |
252 }; | 252 }; |
| 253 |
| 254 enum class FunctionBodyType { |
| 255 kNormal, |
| 256 kSingleExpression |
| 257 }; |
253 // clang-format on | 258 // clang-format on |
254 | 259 |
255 class Checkpoint; | 260 class Checkpoint; |
256 class ClassLiteralChecker; | 261 class ClassLiteralChecker; |
257 class ObjectLiteralChecker; | 262 class ObjectLiteralChecker; |
258 | 263 |
259 // --------------------------------------------------------------------------- | 264 // --------------------------------------------------------------------------- |
260 // ScopeState and its subclasses implement the parser's scope stack. | 265 // ScopeState and its subclasses implement the parser's scope stack. |
261 // ScopeState keeps track of the current scope, and the outer ScopeState. The | 266 // ScopeState keeps track of the current scope, and the outer ScopeState. The |
262 // parser's scope_state_ points to the top ScopeState. ScopeState's | 267 // parser's scope_state_ points to the top ScopeState. ScopeState's |
(...skipping 921 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1184 ExpressionT ParseUnaryExpression(bool* ok); | 1189 ExpressionT ParseUnaryExpression(bool* ok); |
1185 ExpressionT ParsePostfixExpression(bool* ok); | 1190 ExpressionT ParsePostfixExpression(bool* ok); |
1186 ExpressionT ParseLeftHandSideExpression(bool* ok); | 1191 ExpressionT ParseLeftHandSideExpression(bool* ok); |
1187 ExpressionT ParseMemberWithNewPrefixesExpression(bool* is_async, bool* ok); | 1192 ExpressionT ParseMemberWithNewPrefixesExpression(bool* is_async, bool* ok); |
1188 ExpressionT ParseMemberExpression(bool* is_async, bool* ok); | 1193 ExpressionT ParseMemberExpression(bool* is_async, bool* ok); |
1189 ExpressionT ParseMemberExpressionContinuation(ExpressionT expression, | 1194 ExpressionT ParseMemberExpressionContinuation(ExpressionT expression, |
1190 bool* is_async, bool* ok); | 1195 bool* is_async, bool* ok); |
1191 ExpressionT ParseArrowFunctionLiteral(bool accept_IN, | 1196 ExpressionT ParseArrowFunctionLiteral(bool accept_IN, |
1192 const FormalParametersT& parameters, | 1197 const FormalParametersT& parameters, |
1193 bool* ok); | 1198 bool* ok); |
| 1199 void ParseAsyncFunctionBody(Scope* scope, StatementListT body, |
| 1200 FunctionKind kind, FunctionBodyType type, |
| 1201 bool accept_IN, int pos, bool* ok); |
| 1202 ExpressionT ParseAsyncFunctionLiteral(bool* ok); |
1194 ExpressionT ParseTemplateLiteral(ExpressionT tag, int start, bool* ok); | 1203 ExpressionT ParseTemplateLiteral(ExpressionT tag, int start, bool* ok); |
1195 ExpressionT ParseSuperExpression(bool is_new, bool* ok); | 1204 ExpressionT ParseSuperExpression(bool is_new, bool* ok); |
1196 ExpressionT ParseNewTargetExpression(bool* ok); | 1205 ExpressionT ParseNewTargetExpression(bool* ok); |
1197 | 1206 |
1198 void ParseFormalParameter(FormalParametersT* parameters, bool* ok); | 1207 void ParseFormalParameter(FormalParametersT* parameters, bool* ok); |
1199 void ParseFormalParameterList(FormalParametersT* parameters, bool* ok); | 1208 void ParseFormalParameterList(FormalParametersT* parameters, bool* ok); |
1200 void CheckArityRestrictions(int param_count, FunctionKind function_type, | 1209 void CheckArityRestrictions(int param_count, FunctionKind function_type, |
1201 bool has_rest, int formals_start_pos, | 1210 bool has_rest, int formals_start_pos, |
1202 int formals_end_pos, bool* ok); | 1211 int formals_end_pos, bool* ok); |
1203 | 1212 |
1204 BlockT ParseVariableDeclarations(VariableDeclarationContext var_context, | 1213 BlockT ParseVariableDeclarations(VariableDeclarationContext var_context, |
1205 DeclarationParsingResult* parsing_result, | 1214 DeclarationParsingResult* parsing_result, |
1206 ZoneList<const AstRawString*>* names, | 1215 ZoneList<const AstRawString*>* names, |
1207 bool* ok); | 1216 bool* ok); |
| 1217 StatementT ParseAsyncFunctionDeclaration(ZoneList<const AstRawString*>* names, |
| 1218 bool default_export, bool* ok); |
1208 StatementT ParseHoistableDeclaration(ZoneList<const AstRawString*>* names, | 1219 StatementT ParseHoistableDeclaration(ZoneList<const AstRawString*>* names, |
1209 bool default_export, bool* ok); | 1220 bool default_export, bool* ok); |
1210 StatementT ParseHoistableDeclaration(int pos, ParseFunctionFlags flags, | 1221 StatementT ParseHoistableDeclaration(int pos, ParseFunctionFlags flags, |
1211 ZoneList<const AstRawString*>* names, | 1222 ZoneList<const AstRawString*>* names, |
1212 bool default_export, bool* ok); | 1223 bool default_export, bool* ok); |
1213 | 1224 |
1214 // Under some circumstances, we allow preparsing to abort if the preparsed | 1225 // Under some circumstances, we allow preparsing to abort if the preparsed |
1215 // function is "long and trivial", and fully parse instead. Our current | 1226 // function is "long and trivial", and fully parse instead. Our current |
1216 // definition of "long and trivial" is: | 1227 // definition of "long and trivial" is: |
1217 // - over kLazyParseTrialLimit statements | 1228 // - over kLazyParseTrialLimit statements |
(...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1700 // Identifier | 1711 // Identifier |
1701 // Number | 1712 // Number |
1702 // String | 1713 // String |
1703 // ArrayLiteral | 1714 // ArrayLiteral |
1704 // ObjectLiteral | 1715 // ObjectLiteral |
1705 // RegExpLiteral | 1716 // RegExpLiteral |
1706 // ClassLiteral | 1717 // ClassLiteral |
1707 // '(' Expression ')' | 1718 // '(' Expression ')' |
1708 // TemplateLiteral | 1719 // TemplateLiteral |
1709 // do Block | 1720 // do Block |
1710 // AsyncFunctionExpression | 1721 // AsyncFunctionLiteral |
1711 | 1722 |
1712 int beg_pos = peek_position(); | 1723 int beg_pos = peek_position(); |
1713 switch (peek()) { | 1724 switch (peek()) { |
1714 case Token::THIS: { | 1725 case Token::THIS: { |
1715 BindingPatternUnexpectedToken(); | 1726 BindingPatternUnexpectedToken(); |
1716 Consume(Token::THIS); | 1727 Consume(Token::THIS); |
1717 return impl()->ThisExpression(beg_pos); | 1728 return impl()->ThisExpression(beg_pos); |
1718 } | 1729 } |
1719 | 1730 |
1720 case Token::NULL_LITERAL: | 1731 case Token::NULL_LITERAL: |
1721 case Token::TRUE_LITERAL: | 1732 case Token::TRUE_LITERAL: |
1722 case Token::FALSE_LITERAL: | 1733 case Token::FALSE_LITERAL: |
1723 case Token::SMI: | 1734 case Token::SMI: |
1724 case Token::NUMBER: | 1735 case Token::NUMBER: |
1725 BindingPatternUnexpectedToken(); | 1736 BindingPatternUnexpectedToken(); |
1726 return impl()->ExpressionFromLiteral(Next(), beg_pos); | 1737 return impl()->ExpressionFromLiteral(Next(), beg_pos); |
1727 | 1738 |
1728 case Token::ASYNC: | 1739 case Token::ASYNC: |
1729 if (allow_harmony_async_await() && | 1740 if (allow_harmony_async_await() && |
1730 !scanner()->HasAnyLineTerminatorAfterNext() && | 1741 !scanner()->HasAnyLineTerminatorAfterNext() && |
1731 PeekAhead() == Token::FUNCTION) { | 1742 PeekAhead() == Token::FUNCTION) { |
1732 Consume(Token::ASYNC); | 1743 Consume(Token::ASYNC); |
1733 return impl()->ParseAsyncFunctionExpression(CHECK_OK); | 1744 return ParseAsyncFunctionLiteral(CHECK_OK); |
1734 } | 1745 } |
1735 // CoverCallExpressionAndAsyncArrowHead | 1746 // CoverCallExpressionAndAsyncArrowHead |
1736 *is_async = true; | 1747 *is_async = true; |
1737 /* falls through */ | 1748 /* falls through */ |
1738 case Token::IDENTIFIER: | 1749 case Token::IDENTIFIER: |
1739 case Token::LET: | 1750 case Token::LET: |
1740 case Token::STATIC: | 1751 case Token::STATIC: |
1741 case Token::YIELD: | 1752 case Token::YIELD: |
1742 case Token::AWAIT: | 1753 case Token::AWAIT: |
1743 case Token::ESCAPED_STRICT_RESERVED_WORD: | 1754 case Token::ESCAPED_STRICT_RESERVED_WORD: |
(...skipping 916 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2660 ValidateFormalParameterInitializer(ok); | 2671 ValidateFormalParameterInitializer(ok); |
2661 | 2672 |
2662 Scanner::Location loc(lhs_beg_pos, scanner()->location().end_pos); | 2673 Scanner::Location loc(lhs_beg_pos, scanner()->location().end_pos); |
2663 DeclarationScope* scope = | 2674 DeclarationScope* scope = |
2664 NewFunctionScope(is_async ? FunctionKind::kAsyncArrowFunction | 2675 NewFunctionScope(is_async ? FunctionKind::kAsyncArrowFunction |
2665 : FunctionKind::kArrowFunction); | 2676 : FunctionKind::kArrowFunction); |
2666 // Because the arrow's parameters were parsed in the outer scope, any | 2677 // Because the arrow's parameters were parsed in the outer scope, any |
2667 // usage flags that might have been triggered there need to be copied | 2678 // usage flags that might have been triggered there need to be copied |
2668 // to the arrow scope. | 2679 // to the arrow scope. |
2669 this->scope()->PropagateUsageFlagsToScope(scope); | 2680 this->scope()->PropagateUsageFlagsToScope(scope); |
| 2681 |
| 2682 scope_snapshot.Reparent(scope); |
| 2683 |
2670 FormalParametersT parameters(scope); | 2684 FormalParametersT parameters(scope); |
2671 if (!classifier()->is_simple_parameter_list()) { | 2685 if (!classifier()->is_simple_parameter_list()) { |
2672 scope->SetHasNonSimpleParameters(); | 2686 scope->SetHasNonSimpleParameters(); |
2673 parameters.is_simple = false; | 2687 parameters.is_simple = false; |
2674 } | 2688 } |
2675 | 2689 |
2676 checkpoint.Restore(¶meters.materialized_literals_count); | 2690 checkpoint.Restore(¶meters.materialized_literals_count); |
2677 | 2691 |
2678 scope->set_start_position(lhs_beg_pos); | 2692 scope->set_start_position(lhs_beg_pos); |
2679 Scanner::Location duplicate_loc = Scanner::Location::invalid(); | 2693 Scanner::Location duplicate_loc = Scanner::Location::invalid(); |
2680 impl()->ParseArrowFunctionFormalParameterList( | 2694 impl()->DeclareArrowFunctionFormalParameters(¶meters, expression, loc, |
2681 ¶meters, expression, loc, &duplicate_loc, scope_snapshot, CHECK_OK); | 2695 &duplicate_loc, CHECK_OK); |
2682 if (duplicate_loc.IsValid()) { | 2696 if (duplicate_loc.IsValid()) { |
2683 classifier()->RecordDuplicateFormalParameterError(duplicate_loc); | 2697 classifier()->RecordDuplicateFormalParameterError(duplicate_loc); |
2684 } | 2698 } |
2685 expression = ParseArrowFunctionLiteral(accept_IN, parameters, CHECK_OK); | 2699 expression = ParseArrowFunctionLiteral(accept_IN, parameters, CHECK_OK); |
2686 impl()->Discard(); | 2700 impl()->Discard(); |
2687 classifier()->RecordPatternError(arrow_loc, | 2701 classifier()->RecordPatternError(arrow_loc, |
2688 MessageTemplate::kUnexpectedToken, | 2702 MessageTemplate::kUnexpectedToken, |
2689 Token::String(Token::ARROW)); | 2703 Token::String(Token::ARROW)); |
2690 | 2704 |
2691 if (fni_ != nullptr) fni_->Infer(); | 2705 if (fni_ != nullptr) fni_->Infer(); |
(...skipping 1107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3799 : is_async ? FunctionKind::kAsyncFunction | 3813 : is_async ? FunctionKind::kAsyncFunction |
3800 : FunctionKind::kNormalFunction, | 3814 : FunctionKind::kNormalFunction, |
3801 pos, FunctionLiteral::kDeclaration, language_mode(), | 3815 pos, FunctionLiteral::kDeclaration, language_mode(), |
3802 CHECK_OK_CUSTOM(NullStatement)); | 3816 CHECK_OK_CUSTOM(NullStatement)); |
3803 | 3817 |
3804 return impl()->DeclareFunction(variable_name, function, pos, is_generator, | 3818 return impl()->DeclareFunction(variable_name, function, pos, is_generator, |
3805 is_async, names, ok); | 3819 is_async, names, ok); |
3806 } | 3820 } |
3807 | 3821 |
3808 template <typename Impl> | 3822 template <typename Impl> |
| 3823 typename ParserBase<Impl>::StatementT |
| 3824 ParserBase<Impl>::ParseAsyncFunctionDeclaration( |
| 3825 ZoneList<const AstRawString*>* names, bool default_export, bool* ok) { |
| 3826 // AsyncFunctionDeclaration :: |
| 3827 // async [no LineTerminator here] function BindingIdentifier[Await] |
| 3828 // ( FormalParameters[Await] ) { AsyncFunctionBody } |
| 3829 DCHECK_EQ(scanner()->current_token(), Token::ASYNC); |
| 3830 int pos = position(); |
| 3831 if (scanner()->HasAnyLineTerminatorBeforeNext()) { |
| 3832 *ok = false; |
| 3833 impl()->ReportUnexpectedToken(scanner()->current_token()); |
| 3834 return impl()->NullStatement(); |
| 3835 } |
| 3836 Expect(Token::FUNCTION, CHECK_OK_CUSTOM(NullStatement)); |
| 3837 ParseFunctionFlags flags = ParseFunctionFlags::kIsAsync; |
| 3838 return ParseHoistableDeclaration(pos, flags, names, default_export, ok); |
| 3839 } |
| 3840 |
| 3841 template <typename Impl> |
3809 void ParserBase<Impl>::CheckArityRestrictions(int param_count, | 3842 void ParserBase<Impl>::CheckArityRestrictions(int param_count, |
3810 FunctionKind function_kind, | 3843 FunctionKind function_kind, |
3811 bool has_rest, | 3844 bool has_rest, |
3812 int formals_start_pos, | 3845 int formals_start_pos, |
3813 int formals_end_pos, bool* ok) { | 3846 int formals_end_pos, bool* ok) { |
3814 if (IsGetterFunction(function_kind)) { | 3847 if (IsGetterFunction(function_kind)) { |
3815 if (param_count != 0) { | 3848 if (param_count != 0) { |
3816 impl()->ReportMessageAt( | 3849 impl()->ReportMessageAt( |
3817 Scanner::Location(formals_start_pos, formals_end_pos), | 3850 Scanner::Location(formals_start_pos, formals_end_pos), |
3818 MessageTemplate::kBadGetterArity); | 3851 MessageTemplate::kBadGetterArity); |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3957 int pos = position(); | 3990 int pos = position(); |
3958 DCHECK(ReturnExprContext::kInsideValidBlock == | 3991 DCHECK(ReturnExprContext::kInsideValidBlock == |
3959 function_state_->return_expr_context()); | 3992 function_state_->return_expr_context()); |
3960 ReturnExprScope allow_tail_calls( | 3993 ReturnExprScope allow_tail_calls( |
3961 function_state_, ReturnExprContext::kInsideValidReturnStatement); | 3994 function_state_, ReturnExprContext::kInsideValidReturnStatement); |
3962 body = impl()->NewStatementList(1); | 3995 body = impl()->NewStatementList(1); |
3963 impl()->AddParameterInitializationBlock( | 3996 impl()->AddParameterInitializationBlock( |
3964 formal_parameters, body, kind == kAsyncArrowFunction, CHECK_OK); | 3997 formal_parameters, body, kind == kAsyncArrowFunction, CHECK_OK); |
3965 ExpressionClassifier classifier(this); | 3998 ExpressionClassifier classifier(this); |
3966 if (kind == kAsyncArrowFunction) { | 3999 if (kind == kAsyncArrowFunction) { |
3967 impl()->ParseAsyncArrowSingleExpressionBody(body, accept_IN, pos, | 4000 ParseAsyncFunctionBody(scope(), body, kAsyncArrowFunction, |
3968 CHECK_OK); | 4001 FunctionBodyType::kSingleExpression, accept_IN, |
| 4002 pos, CHECK_OK); |
3969 impl()->RewriteNonPattern(CHECK_OK); | 4003 impl()->RewriteNonPattern(CHECK_OK); |
3970 } else { | 4004 } else { |
3971 ExpressionT expression = ParseAssignmentExpression(accept_IN, CHECK_OK); | 4005 ExpressionT expression = ParseAssignmentExpression(accept_IN, CHECK_OK); |
3972 impl()->RewriteNonPattern(CHECK_OK); | 4006 impl()->RewriteNonPattern(CHECK_OK); |
3973 body->Add(factory()->NewReturnStatement(expression, pos), zone()); | 4007 body->Add(factory()->NewReturnStatement(expression, pos), zone()); |
3974 if (allow_tailcalls() && !is_sloppy(language_mode())) { | 4008 if (allow_tailcalls() && !is_sloppy(language_mode())) { |
3975 // ES6 14.6.1 Static Semantics: IsInTailPosition | 4009 // ES6 14.6.1 Static Semantics: IsInTailPosition |
3976 impl()->MarkTailPosition(expression); | 4010 impl()->MarkTailPosition(expression); |
3977 } | 4011 } |
3978 } | 4012 } |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4013 if (should_be_used_once_hint) { | 4047 if (should_be_used_once_hint) { |
4014 function_literal->set_should_be_used_once_hint(); | 4048 function_literal->set_should_be_used_once_hint(); |
4015 } | 4049 } |
4016 | 4050 |
4017 impl()->InferFunctionName(function_literal); | 4051 impl()->InferFunctionName(function_literal); |
4018 | 4052 |
4019 return function_literal; | 4053 return function_literal; |
4020 } | 4054 } |
4021 | 4055 |
4022 template <typename Impl> | 4056 template <typename Impl> |
| 4057 void ParserBase<Impl>::ParseAsyncFunctionBody(Scope* scope, StatementListT body, |
| 4058 FunctionKind kind, |
| 4059 FunctionBodyType body_type, |
| 4060 bool accept_IN, int pos, |
| 4061 bool* ok) { |
| 4062 scope->ForceContextAllocation(); |
| 4063 |
| 4064 impl()->PrepareAsyncFunctionBody(body, kind, pos); |
| 4065 |
| 4066 BlockT block = factory()->NewBlock(nullptr, 8, true, kNoSourcePosition); |
| 4067 |
| 4068 ExpressionT return_value = impl()->EmptyExpression(); |
| 4069 if (body_type == FunctionBodyType::kNormal) { |
| 4070 ParseStatementList(block->statements(), Token::RBRACE, |
| 4071 CHECK_OK_CUSTOM(Void)); |
| 4072 return_value = factory()->NewUndefinedLiteral(kNoSourcePosition); |
| 4073 } else { |
| 4074 return_value = ParseAssignmentExpression(accept_IN, CHECK_OK_CUSTOM(Void)); |
| 4075 impl()->RewriteNonPattern(CHECK_OK_CUSTOM(Void)); |
| 4076 } |
| 4077 |
| 4078 impl()->RewriteAsyncFunctionBody(body, block, return_value, |
| 4079 CHECK_OK_CUSTOM(Void)); |
| 4080 scope->set_end_position(scanner()->location().end_pos); |
| 4081 } |
| 4082 |
| 4083 template <typename Impl> |
| 4084 typename ParserBase<Impl>::ExpressionT |
| 4085 ParserBase<Impl>::ParseAsyncFunctionLiteral(bool* ok) { |
| 4086 // AsyncFunctionLiteral :: |
| 4087 // async [no LineTerminator here] function ( FormalParameters[Await] ) |
| 4088 // { AsyncFunctionBody } |
| 4089 // |
| 4090 // async [no LineTerminator here] function BindingIdentifier[Await] |
| 4091 // ( FormalParameters[Await] ) { AsyncFunctionBody } |
| 4092 DCHECK_EQ(scanner()->current_token(), Token::ASYNC); |
| 4093 int pos = position(); |
| 4094 Expect(Token::FUNCTION, CHECK_OK); |
| 4095 bool is_strict_reserved = false; |
| 4096 IdentifierT name = impl()->EmptyIdentifier(); |
| 4097 FunctionLiteral::FunctionType type = FunctionLiteral::kAnonymousExpression; |
| 4098 |
| 4099 if (peek_any_identifier()) { |
| 4100 type = FunctionLiteral::kNamedExpression; |
| 4101 name = ParseIdentifierOrStrictReservedWord(FunctionKind::kAsyncFunction, |
| 4102 &is_strict_reserved, CHECK_OK); |
| 4103 } |
| 4104 return impl()->ParseFunctionLiteral( |
| 4105 name, scanner()->location(), |
| 4106 is_strict_reserved ? kFunctionNameIsStrictReserved |
| 4107 : kFunctionNameValidityUnknown, |
| 4108 FunctionKind::kAsyncFunction, pos, type, language_mode(), CHECK_OK); |
| 4109 } |
| 4110 |
| 4111 template <typename Impl> |
4023 typename ParserBase<Impl>::ExpressionT ParserBase<Impl>::ParseTemplateLiteral( | 4112 typename ParserBase<Impl>::ExpressionT ParserBase<Impl>::ParseTemplateLiteral( |
4024 ExpressionT tag, int start, bool* ok) { | 4113 ExpressionT tag, int start, bool* ok) { |
4025 // A TemplateLiteral is made up of 0 or more TEMPLATE_SPAN tokens (literal | 4114 // A TemplateLiteral is made up of 0 or more TEMPLATE_SPAN tokens (literal |
4026 // text followed by a substitution expression), finalized by a single | 4115 // text followed by a substitution expression), finalized by a single |
4027 // TEMPLATE_TAIL. | 4116 // TEMPLATE_TAIL. |
4028 // | 4117 // |
4029 // In terms of draft language, TEMPLATE_SPAN may be either the TemplateHead or | 4118 // In terms of draft language, TEMPLATE_SPAN may be either the TemplateHead or |
4030 // TemplateMiddle productions, while TEMPLATE_TAIL is either TemplateTail, or | 4119 // TemplateMiddle productions, while TEMPLATE_TAIL is either TemplateTail, or |
4031 // NoSubstitutionTemplate. | 4120 // NoSubstitutionTemplate. |
4032 // | 4121 // |
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4322 return ParseVariableStatement(kStatementListItem, nullptr, ok); | 4411 return ParseVariableStatement(kStatementListItem, nullptr, ok); |
4323 case Token::LET: | 4412 case Token::LET: |
4324 if (IsNextLetKeyword()) { | 4413 if (IsNextLetKeyword()) { |
4325 return ParseVariableStatement(kStatementListItem, nullptr, ok); | 4414 return ParseVariableStatement(kStatementListItem, nullptr, ok); |
4326 } | 4415 } |
4327 break; | 4416 break; |
4328 case Token::ASYNC: | 4417 case Token::ASYNC: |
4329 if (allow_harmony_async_await() && PeekAhead() == Token::FUNCTION && | 4418 if (allow_harmony_async_await() && PeekAhead() == Token::FUNCTION && |
4330 !scanner()->HasAnyLineTerminatorAfterNext()) { | 4419 !scanner()->HasAnyLineTerminatorAfterNext()) { |
4331 Consume(Token::ASYNC); | 4420 Consume(Token::ASYNC); |
4332 return impl()->ParseAsyncFunctionDeclaration(nullptr, false, ok); | 4421 return ParseAsyncFunctionDeclaration(nullptr, false, ok); |
4333 } | 4422 } |
4334 /* falls through */ | 4423 /* falls through */ |
4335 default: | 4424 default: |
4336 break; | 4425 break; |
4337 } | 4426 } |
4338 return ParseStatement(nullptr, kAllowLabelledFunctionStatement, ok); | 4427 return ParseStatement(nullptr, kAllowLabelledFunctionStatement, ok); |
4339 } | 4428 } |
4340 | 4429 |
4341 template <typename Impl> | 4430 template <typename Impl> |
4342 typename ParserBase<Impl>::StatementT ParserBase<Impl>::ParseStatement( | 4431 typename ParserBase<Impl>::StatementT ParserBase<Impl>::ParseStatement( |
(...skipping 981 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5324 has_seen_constructor_ = true; | 5413 has_seen_constructor_ = true; |
5325 return; | 5414 return; |
5326 } | 5415 } |
5327 } | 5416 } |
5328 | 5417 |
5329 | 5418 |
5330 } // namespace internal | 5419 } // namespace internal |
5331 } // namespace v8 | 5420 } // namespace v8 |
5332 | 5421 |
5333 #endif // V8_PARSING_PARSER_BASE_H | 5422 #endif // V8_PARSING_PARSER_BASE_H |
OLD | NEW |