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 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
337 bool peek_any_identifier() { | 337 bool peek_any_identifier() { |
338 Token::Value next = peek(); | 338 Token::Value next = peek(); |
339 return next == Token::IDENTIFIER || | 339 return next == Token::IDENTIFIER || |
340 next == Token::FUTURE_RESERVED_WORD || | 340 next == Token::FUTURE_RESERVED_WORD || |
341 next == Token::FUTURE_STRICT_RESERVED_WORD || | 341 next == Token::FUTURE_STRICT_RESERVED_WORD || |
342 next == Token::LET || | 342 next == Token::LET || |
343 next == Token::YIELD; | 343 next == Token::YIELD; |
344 } | 344 } |
345 | 345 |
346 bool CheckContextualKeyword(Vector<const char> keyword) { | 346 bool CheckContextualKeyword(Vector<const char> keyword) { |
347 if (peek() == Token::IDENTIFIER && | 347 if (PeekContextualKeyword(keyword)) { |
348 scanner()->is_next_contextual_keyword(keyword)) { | |
349 Consume(Token::IDENTIFIER); | 348 Consume(Token::IDENTIFIER); |
350 return true; | 349 return true; |
351 } | 350 } |
352 return false; | 351 return false; |
353 } | 352 } |
354 | 353 |
| 354 bool PeekContextualKeyword(Vector<const char> keyword) { |
| 355 return peek() == Token::IDENTIFIER && |
| 356 scanner()->is_next_contextual_keyword(keyword); |
| 357 } |
| 358 |
355 void ExpectContextualKeyword(Vector<const char> keyword, bool* ok) { | 359 void ExpectContextualKeyword(Vector<const char> keyword, bool* ok) { |
356 Expect(Token::IDENTIFIER, ok); | 360 Expect(Token::IDENTIFIER, ok); |
357 if (!*ok) return; | 361 if (!*ok) return; |
358 if (!scanner()->is_literal_contextual_keyword(keyword)) { | 362 if (!scanner()->is_literal_contextual_keyword(keyword)) { |
359 ReportUnexpectedToken(scanner()->current_token()); | 363 ReportUnexpectedToken(scanner()->current_token()); |
360 *ok = false; | 364 *ok = false; |
361 } | 365 } |
362 } | 366 } |
363 | 367 |
364 // Checks whether an octal literal was last seen between beg_pos and end_pos. | 368 // Checks whether an octal literal was last seen between beg_pos and end_pos. |
(...skipping 2462 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2827 DCHECK(IsAccessorAccessorConflict(old_type, type)); | 2831 DCHECK(IsAccessorAccessorConflict(old_type, type)); |
2828 // Both accessors of the same type. | 2832 // Both accessors of the same type. |
2829 parser()->ReportMessage("accessor_get_set"); | 2833 parser()->ReportMessage("accessor_get_set"); |
2830 } | 2834 } |
2831 *ok = false; | 2835 *ok = false; |
2832 } | 2836 } |
2833 } | 2837 } |
2834 } } // v8::internal | 2838 } } // v8::internal |
2835 | 2839 |
2836 #endif // V8_PREPARSER_H | 2840 #endif // V8_PREPARSER_H |
OLD | NEW |