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 456 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
467 private: | 467 private: |
468 JavaScriptScanner* scanner_; | 468 JavaScriptScanner* scanner_; |
469 bool complete_; | 469 bool complete_; |
470 }; | 470 }; |
471 | 471 |
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 // possibly inside a multi-line comment. |
479 return has_line_terminator_before_next_; | 479 bool HasAnyLineTerminatorBeforeNext() const { |
| 480 return has_line_terminator_before_next_ || |
| 481 has_multiline_comment_before_next_; |
480 } | 482 } |
481 | 483 |
482 // Scans the input as a regular expression pattern, previous | 484 // Scans the input as a regular expression pattern, previous |
483 // character(s) must be /(=). Returns true if a pattern is scanned. | 485 // character(s) must be /(=). Returns true if a pattern is scanned. |
484 bool ScanRegExpPattern(bool seen_equal); | 486 bool ScanRegExpPattern(bool seen_equal); |
485 // Returns true if regexp flags are scanned (always since flags can | 487 // Returns true if regexp flags are scanned (always since flags can |
486 // be empty). | 488 // be empty). |
487 bool ScanRegExpFlags(); | 489 bool ScanRegExpFlags(); |
488 | 490 |
489 // Tells whether the buffer contains an identifier (no escapes). | 491 // Tells whether the buffer contains an identifier (no escapes). |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
522 // Scans a possible HTML comment -- begins with '<!'. | 524 // Scans a possible HTML comment -- begins with '<!'. |
523 Token::Value ScanHtmlComment(); | 525 Token::Value ScanHtmlComment(); |
524 | 526 |
525 // Decodes a unicode escape-sequence which is part of an identifier. | 527 // Decodes a unicode escape-sequence which is part of an identifier. |
526 // If the escape sequence cannot be decoded the result is kBadChar. | 528 // If the escape sequence cannot be decoded the result is kBadChar. |
527 uc32 ScanIdentifierUnicodeEscape(); | 529 uc32 ScanIdentifierUnicodeEscape(); |
528 | 530 |
529 // Start position of the octal literal last scanned. | 531 // Start position of the octal literal last scanned. |
530 Location octal_pos_; | 532 Location octal_pos_; |
531 | 533 |
| 534 // Whether there is a line terminator whitespace character after |
| 535 // the current token, and before the next. Does not count newlines |
| 536 // inside multiline comments. |
532 bool has_line_terminator_before_next_; | 537 bool has_line_terminator_before_next_; |
| 538 // Whether there is a multi-line comment that containins a |
| 539 // line-terminator after the current token, and before the next. |
| 540 bool has_multiline_comment_before_next_; |
533 }; | 541 }; |
534 | 542 |
535 | 543 |
536 // ---------------------------------------------------------------------------- | 544 // ---------------------------------------------------------------------------- |
537 // Keyword matching state machine. | 545 // Keyword matching state machine. |
538 | 546 |
539 class KeywordMatcher { | 547 class KeywordMatcher { |
540 // Incrementally recognize keywords. | 548 // Incrementally recognize keywords. |
541 // | 549 // |
542 // Recognized keywords: | 550 // Recognized keywords: |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
661 // keyword with the current prefix). | 669 // keyword with the current prefix). |
662 const char* keyword_; | 670 const char* keyword_; |
663 int counter_; | 671 int counter_; |
664 Token::Value keyword_token_; | 672 Token::Value keyword_token_; |
665 }; | 673 }; |
666 | 674 |
667 | 675 |
668 } } // namespace v8::internal | 676 } } // namespace v8::internal |
669 | 677 |
670 #endif // V8_SCANNER_BASE_H_ | 678 #endif // V8_SCANNER_BASE_H_ |
OLD | NEW |