| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 472 explicit JavaScriptScanner(UnicodeCache* scanner_contants); | 472 explicit JavaScriptScanner(UnicodeCache* scanner_contants); |
| 473 | 473 |
| 474 // Returns the next token. | 474 // Returns the next token. |
| 475 Token::Value Next(); | 475 Token::Value Next(); |
| 476 | 476 |
| 477 // Returns true if there was a line terminator before the peek'ed token. | 477 // Returns true if there was a line terminator before the peek'ed token. |
| 478 bool has_line_terminator_before_next() const { | 478 bool has_line_terminator_before_next() const { |
| 479 return has_line_terminator_before_next_; | 479 return has_line_terminator_before_next_; |
| 480 } | 480 } |
| 481 | 481 |
| 482 // Returns true if there was no non-whitespace on the line before the |
| 483 // peek'ed token. |
| 484 bool next_is_first_on_line() const { |
| 485 return next_is_first_on_line_; |
| 486 } |
| 487 |
| 482 // Scans the input as a regular expression pattern, previous | 488 // Scans the input as a regular expression pattern, previous |
| 483 // character(s) must be /(=). Returns true if a pattern is scanned. | 489 // character(s) must be /(=). Returns true if a pattern is scanned. |
| 484 bool ScanRegExpPattern(bool seen_equal); | 490 bool ScanRegExpPattern(bool seen_equal); |
| 485 // Returns true if regexp flags are scanned (always since flags can | 491 // Returns true if regexp flags are scanned (always since flags can |
| 486 // be empty). | 492 // be empty). |
| 487 bool ScanRegExpFlags(); | 493 bool ScanRegExpFlags(); |
| 488 | 494 |
| 489 // Tells whether the buffer contains an identifier (no escapes). | 495 // Tells whether the buffer contains an identifier (no escapes). |
| 490 // Used for checking if a property name is an identifier. | 496 // Used for checking if a property name is an identifier. |
| 491 static bool IsIdentifier(unibrow::CharacterStream* buffer); | 497 static bool IsIdentifier(unibrow::CharacterStream* buffer); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 522 // Scans a possible HTML comment -- begins with '<!'. | 528 // Scans a possible HTML comment -- begins with '<!'. |
| 523 Token::Value ScanHtmlComment(); | 529 Token::Value ScanHtmlComment(); |
| 524 | 530 |
| 525 // Decodes a unicode escape-sequence which is part of an identifier. | 531 // Decodes a unicode escape-sequence which is part of an identifier. |
| 526 // If the escape sequence cannot be decoded the result is kBadChar. | 532 // If the escape sequence cannot be decoded the result is kBadChar. |
| 527 uc32 ScanIdentifierUnicodeEscape(); | 533 uc32 ScanIdentifierUnicodeEscape(); |
| 528 | 534 |
| 529 // Start position of the octal literal last scanned. | 535 // Start position of the octal literal last scanned. |
| 530 Location octal_pos_; | 536 Location octal_pos_; |
| 531 | 537 |
| 538 // Whether there is a line terminator between the current proper |
| 539 // token and the next one (ignoring whitespace tokens and comments). |
| 532 bool has_line_terminator_before_next_; | 540 bool has_line_terminator_before_next_; |
| 541 // Whether there is only whitespace (and not comments) on the current |
| 542 // line until now. |
| 543 bool next_is_first_on_line_; |
| 533 }; | 544 }; |
| 534 | 545 |
| 535 | 546 |
| 536 // ---------------------------------------------------------------------------- | 547 // ---------------------------------------------------------------------------- |
| 537 // Keyword matching state machine. | 548 // Keyword matching state machine. |
| 538 | 549 |
| 539 class KeywordMatcher { | 550 class KeywordMatcher { |
| 540 // Incrementally recognize keywords. | 551 // Incrementally recognize keywords. |
| 541 // | 552 // |
| 542 // Recognized keywords: | 553 // Recognized keywords: |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 661 // keyword with the current prefix). | 672 // keyword with the current prefix). |
| 662 const char* keyword_; | 673 const char* keyword_; |
| 663 int counter_; | 674 int counter_; |
| 664 Token::Value keyword_token_; | 675 Token::Value keyword_token_; |
| 665 }; | 676 }; |
| 666 | 677 |
| 667 | 678 |
| 668 } } // namespace v8::internal | 679 } } // namespace v8::internal |
| 669 | 680 |
| 670 #endif // V8_SCANNER_BASE_H_ | 681 #endif // V8_SCANNER_BASE_H_ |
| OLD | NEW |