| 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/v8.h" | 8 #include "src/v8.h" |
| 9 | 9 |
| 10 #include "src/bailout-reason.h" | 10 #include "src/bailout-reason.h" |
| (...skipping 2152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2163 case Token::TRUE_LITERAL: | 2163 case Token::TRUE_LITERAL: |
| 2164 case Token::FALSE_LITERAL: | 2164 case Token::FALSE_LITERAL: |
| 2165 BindingPatternUnexpectedToken(classifier); | 2165 BindingPatternUnexpectedToken(classifier); |
| 2166 Next(); | 2166 Next(); |
| 2167 result = | 2167 result = |
| 2168 this->ExpressionFromLiteral(token, beg_pos, scanner(), factory()); | 2168 this->ExpressionFromLiteral(token, beg_pos, scanner(), factory()); |
| 2169 break; | 2169 break; |
| 2170 case Token::SMI: | 2170 case Token::SMI: |
| 2171 case Token::NUMBER: | 2171 case Token::NUMBER: |
| 2172 classifier->RecordBindingPatternError( | 2172 classifier->RecordBindingPatternError( |
| 2173 scanner()->location(), MessageTemplate::kUnexpectedTokenNumber); | 2173 scanner()->peek_location(), MessageTemplate::kUnexpectedTokenNumber); |
| 2174 Next(); | 2174 Next(); |
| 2175 result = | 2175 result = |
| 2176 this->ExpressionFromLiteral(token, beg_pos, scanner(), factory()); | 2176 this->ExpressionFromLiteral(token, beg_pos, scanner(), factory()); |
| 2177 break; | 2177 break; |
| 2178 | 2178 |
| 2179 case Token::IDENTIFIER: | 2179 case Token::IDENTIFIER: |
| 2180 case Token::LET: | 2180 case Token::LET: |
| 2181 case Token::STATIC: | 2181 case Token::STATIC: |
| 2182 case Token::YIELD: | 2182 case Token::YIELD: |
| 2183 case Token::FUTURE_STRICT_RESERVED_WORD: { | 2183 case Token::FUTURE_STRICT_RESERVED_WORD: { |
| 2184 // Using eval or arguments in this context is OK even in strict mode. | 2184 // Using eval or arguments in this context is OK even in strict mode. |
| 2185 IdentifierT name = ParseAndClassifyIdentifier(classifier, CHECK_OK); | 2185 IdentifierT name = ParseAndClassifyIdentifier(classifier, CHECK_OK); |
| 2186 result = this->ExpressionFromIdentifier(name, beg_pos, end_pos, scope_, | 2186 result = this->ExpressionFromIdentifier(name, beg_pos, end_pos, scope_, |
| 2187 factory()); | 2187 factory()); |
| 2188 break; | 2188 break; |
| 2189 } | 2189 } |
| 2190 | 2190 |
| 2191 case Token::STRING: { | 2191 case Token::STRING: { |
| 2192 classifier->RecordBindingPatternError( | 2192 classifier->RecordBindingPatternError( |
| 2193 scanner()->location(), MessageTemplate::kUnexpectedTokenString); | 2193 scanner()->peek_location(), MessageTemplate::kUnexpectedTokenString); |
| 2194 Consume(Token::STRING); | 2194 Consume(Token::STRING); |
| 2195 result = this->ExpressionFromString(beg_pos, scanner(), factory()); | 2195 result = this->ExpressionFromString(beg_pos, scanner(), factory()); |
| 2196 break; | 2196 break; |
| 2197 } | 2197 } |
| 2198 | 2198 |
| 2199 case Token::ASSIGN_DIV: | 2199 case Token::ASSIGN_DIV: |
| 2200 classifier->RecordBindingPatternError( |
| 2201 scanner()->peek_location(), MessageTemplate::kUnexpectedTokenRegExp); |
| 2200 result = this->ParseRegExpLiteral(true, classifier, CHECK_OK); | 2202 result = this->ParseRegExpLiteral(true, classifier, CHECK_OK); |
| 2201 break; | 2203 break; |
| 2202 | 2204 |
| 2203 case Token::DIV: | 2205 case Token::DIV: |
| 2206 classifier->RecordBindingPatternError( |
| 2207 scanner()->peek_location(), MessageTemplate::kUnexpectedTokenRegExp); |
| 2204 result = this->ParseRegExpLiteral(false, classifier, CHECK_OK); | 2208 result = this->ParseRegExpLiteral(false, classifier, CHECK_OK); |
| 2205 break; | 2209 break; |
| 2206 | 2210 |
| 2207 case Token::LBRACK: | 2211 case Token::LBRACK: |
| 2208 if (!allow_harmony_destructuring()) { | 2212 if (!allow_harmony_destructuring()) { |
| 2209 BindingPatternUnexpectedToken(classifier); | 2213 BindingPatternUnexpectedToken(classifier); |
| 2210 } | 2214 } |
| 2211 result = this->ParseArrayLiteral(classifier, CHECK_OK); | 2215 result = this->ParseArrayLiteral(classifier, CHECK_OK); |
| 2212 break; | 2216 break; |
| 2213 | 2217 |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2295 class_name_location = scanner()->location(); | 2299 class_name_location = scanner()->location(); |
| 2296 } | 2300 } |
| 2297 result = this->ParseClassLiteral(name, class_name_location, | 2301 result = this->ParseClassLiteral(name, class_name_location, |
| 2298 is_strict_reserved_name, | 2302 is_strict_reserved_name, |
| 2299 class_token_position, CHECK_OK); | 2303 class_token_position, CHECK_OK); |
| 2300 break; | 2304 break; |
| 2301 } | 2305 } |
| 2302 | 2306 |
| 2303 case Token::TEMPLATE_SPAN: | 2307 case Token::TEMPLATE_SPAN: |
| 2304 case Token::TEMPLATE_TAIL: | 2308 case Token::TEMPLATE_TAIL: |
| 2309 classifier->RecordBindingPatternError( |
| 2310 scanner()->peek_location(), |
| 2311 MessageTemplate::kUnexpectedTemplateString); |
| 2305 result = this->ParseTemplateLiteral(Traits::NoTemplateTag(), beg_pos, | 2312 result = this->ParseTemplateLiteral(Traits::NoTemplateTag(), beg_pos, |
| 2306 classifier, CHECK_OK); | 2313 classifier, CHECK_OK); |
| 2307 break; | 2314 break; |
| 2308 | 2315 |
| 2309 case Token::MOD: | 2316 case Token::MOD: |
| 2310 if (allow_natives() || extension_ != NULL) { | 2317 if (allow_natives() || extension_ != NULL) { |
| 2311 result = this->ParseV8Intrinsic(CHECK_OK); | 2318 result = this->ParseV8Intrinsic(CHECK_OK); |
| 2312 break; | 2319 break; |
| 2313 } | 2320 } |
| 2314 // If we're not allowing special syntax we fall-through to the | 2321 // If we're not allowing special syntax we fall-through to the |
| (...skipping 1665 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3980 *ok = false; | 3987 *ok = false; |
| 3981 return; | 3988 return; |
| 3982 } | 3989 } |
| 3983 has_seen_constructor_ = true; | 3990 has_seen_constructor_ = true; |
| 3984 return; | 3991 return; |
| 3985 } | 3992 } |
| 3986 } | 3993 } |
| 3987 } } // v8::internal | 3994 } } // v8::internal |
| 3988 | 3995 |
| 3989 #endif // V8_PREPARSER_H | 3996 #endif // V8_PREPARSER_H |
| OLD | NEW |