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_PREPARSER_H | 5 #ifndef V8_PREPARSER_H |
6 #define V8_PREPARSER_H | 6 #define V8_PREPARSER_H |
7 | 7 |
8 #include "src/bailout-reason.h" | 8 #include "src/bailout-reason.h" |
9 #include "src/expression-classifier.h" | 9 #include "src/expression-classifier.h" |
10 #include "src/func-name-inferrer.h" | 10 #include "src/func-name-inferrer.h" |
(...skipping 600 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
611 // parameter list, show the "arrow formal parameters" error if the formals | 611 // parameter list, show the "arrow formal parameters" error if the formals |
612 // started with a parenthesis, and the binding pattern error otherwise. | 612 // started with a parenthesis, and the binding pattern error otherwise. |
613 const ExpressionClassifier::Error& error = | 613 const ExpressionClassifier::Error& error = |
614 parenthesized_formals ? classifier->arrow_formal_parameters_error() | 614 parenthesized_formals ? classifier->arrow_formal_parameters_error() |
615 : classifier->binding_pattern_error(); | 615 : classifier->binding_pattern_error(); |
616 ReportClassifierError(error); | 616 ReportClassifierError(error); |
617 *ok = false; | 617 *ok = false; |
618 } | 618 } |
619 } | 619 } |
620 | 620 |
| 621 void ValidateLetPattern(const ExpressionClassifier* classifier, bool* ok) { |
| 622 if (!classifier->is_valid_let_pattern()) { |
| 623 ReportClassifierError(classifier->let_pattern_error()); |
| 624 *ok = false; |
| 625 } |
| 626 } |
| 627 |
621 void ExpressionUnexpectedToken(ExpressionClassifier* classifier) { | 628 void ExpressionUnexpectedToken(ExpressionClassifier* classifier) { |
622 MessageTemplate::Template message = MessageTemplate::kUnexpectedToken; | 629 MessageTemplate::Template message = MessageTemplate::kUnexpectedToken; |
623 const char* arg; | 630 const char* arg; |
624 GetUnexpectedTokenMessage(peek(), &message, &arg); | 631 GetUnexpectedTokenMessage(peek(), &message, &arg); |
625 classifier->RecordExpressionError(scanner()->peek_location(), message, arg); | 632 classifier->RecordExpressionError(scanner()->peek_location(), message, arg); |
626 } | 633 } |
627 | 634 |
628 void BindingPatternUnexpectedToken(ExpressionClassifier* classifier) { | 635 void BindingPatternUnexpectedToken(ExpressionClassifier* classifier) { |
629 MessageTemplate::Template message = MessageTemplate::kUnexpectedToken; | 636 MessageTemplate::Template message = MessageTemplate::kUnexpectedToken; |
630 const char* arg; | 637 const char* arg; |
(...skipping 1454 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2085 scanner()->FindSymbol(classifier->duplicate_finder(), 1) != 0) { | 2092 scanner()->FindSymbol(classifier->duplicate_finder(), 1) != 0) { |
2086 classifier->RecordDuplicateFormalParameterError(scanner()->location()); | 2093 classifier->RecordDuplicateFormalParameterError(scanner()->location()); |
2087 } | 2094 } |
2088 return name; | 2095 return name; |
2089 } else if (is_sloppy(language_mode()) && | 2096 } else if (is_sloppy(language_mode()) && |
2090 (next == Token::FUTURE_STRICT_RESERVED_WORD || | 2097 (next == Token::FUTURE_STRICT_RESERVED_WORD || |
2091 next == Token::LET || next == Token::STATIC || | 2098 next == Token::LET || next == Token::STATIC || |
2092 (next == Token::YIELD && !is_generator()))) { | 2099 (next == Token::YIELD && !is_generator()))) { |
2093 classifier->RecordStrictModeFormalParameterError( | 2100 classifier->RecordStrictModeFormalParameterError( |
2094 scanner()->location(), MessageTemplate::kUnexpectedStrictReserved); | 2101 scanner()->location(), MessageTemplate::kUnexpectedStrictReserved); |
| 2102 if (next == Token::LET) { |
| 2103 classifier->RecordLetPatternError(scanner()->location(), |
| 2104 MessageTemplate::kLetInLexicalBinding); |
| 2105 } |
2095 return this->GetSymbol(scanner()); | 2106 return this->GetSymbol(scanner()); |
2096 } else { | 2107 } else { |
2097 this->ReportUnexpectedToken(next); | 2108 this->ReportUnexpectedToken(next); |
2098 *ok = false; | 2109 *ok = false; |
2099 return Traits::EmptyIdentifier(); | 2110 return Traits::EmptyIdentifier(); |
2100 } | 2111 } |
2101 } | 2112 } |
2102 | 2113 |
2103 | 2114 |
2104 template <class Traits> | 2115 template <class Traits> |
(...skipping 2072 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4177 return; | 4188 return; |
4178 } | 4189 } |
4179 has_seen_constructor_ = true; | 4190 has_seen_constructor_ = true; |
4180 return; | 4191 return; |
4181 } | 4192 } |
4182 } | 4193 } |
4183 } // namespace internal | 4194 } // namespace internal |
4184 } // namespace v8 | 4195 } // namespace v8 |
4185 | 4196 |
4186 #endif // V8_PREPARSER_H | 4197 #endif // V8_PREPARSER_H |
OLD | NEW |