Chromium Code Reviews| 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 // possibly inside a multi-line comment. | |
| 478 bool has_line_terminator_before_next() const { | 479 bool has_line_terminator_before_next() const { |
|
William Hesse
2011/06/21 12:38:54
You can't have a getter which does not get the act
Lasse Reichstein
2011/06/21 13:05:37
That would be using parser-level terminology in th
| |
| 479 return has_line_terminator_before_next_; | 480 // The distinction between newlines as whitespace and newlines inside |
| 481 // multi-line comments only matter inside the scanner. | |
|
William Hesse
2011/06/21 12:38:54
I don't think this sentence makes sense or adds an
Lasse Reichstein
2011/06/21 13:05:37
Again, semicolon-insertion is a parser-level conce
| |
| 482 return has_line_terminator_before_next_ || | |
| 483 has_multiline_comment_before_next_; | |
| 480 } | 484 } |
| 481 | 485 |
| 482 // Scans the input as a regular expression pattern, previous | 486 // Scans the input as a regular expression pattern, previous |
| 483 // character(s) must be /(=). Returns true if a pattern is scanned. | 487 // character(s) must be /(=). Returns true if a pattern is scanned. |
| 484 bool ScanRegExpPattern(bool seen_equal); | 488 bool ScanRegExpPattern(bool seen_equal); |
| 485 // Returns true if regexp flags are scanned (always since flags can | 489 // Returns true if regexp flags are scanned (always since flags can |
| 486 // be empty). | 490 // be empty). |
| 487 bool ScanRegExpFlags(); | 491 bool ScanRegExpFlags(); |
| 488 | 492 |
| 489 // Tells whether the buffer contains an identifier (no escapes). | 493 // 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 '<!'. | 526 // Scans a possible HTML comment -- begins with '<!'. |
| 523 Token::Value ScanHtmlComment(); | 527 Token::Value ScanHtmlComment(); |
| 524 | 528 |
| 525 // Decodes a unicode escape-sequence which is part of an identifier. | 529 // Decodes a unicode escape-sequence which is part of an identifier. |
| 526 // If the escape sequence cannot be decoded the result is kBadChar. | 530 // If the escape sequence cannot be decoded the result is kBadChar. |
| 527 uc32 ScanIdentifierUnicodeEscape(); | 531 uc32 ScanIdentifierUnicodeEscape(); |
| 528 | 532 |
| 529 // Start position of the octal literal last scanned. | 533 // Start position of the octal literal last scanned. |
| 530 Location octal_pos_; | 534 Location octal_pos_; |
| 531 | 535 |
| 536 // Whether there is a line terminator whitespace character after | |
| 537 // the current token, and before the next. Does not count newlines | |
| 538 // inside multiline comments. | |
| 532 bool has_line_terminator_before_next_; | 539 bool has_line_terminator_before_next_; |
| 540 // Whether there is a multi-line comment (actually containing a | |
|
William Hesse
2011/06/21 12:38:54
... comment that actually contains a newline ...
Lasse Reichstein
2011/06/21 13:05:37
Done.
| |
| 541 // line-terminator) after the current token, and before the next. | |
| 542 bool has_multiline_comment_before_next_; | |
| 533 }; | 543 }; |
| 534 | 544 |
| 535 | 545 |
| 536 // ---------------------------------------------------------------------------- | 546 // ---------------------------------------------------------------------------- |
| 537 // Keyword matching state machine. | 547 // Keyword matching state machine. |
| 538 | 548 |
| 539 class KeywordMatcher { | 549 class KeywordMatcher { |
| 540 // Incrementally recognize keywords. | 550 // Incrementally recognize keywords. |
| 541 // | 551 // |
| 542 // Recognized keywords: | 552 // Recognized keywords: |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 661 // keyword with the current prefix). | 671 // keyword with the current prefix). |
| 662 const char* keyword_; | 672 const char* keyword_; |
| 663 int counter_; | 673 int counter_; |
| 664 Token::Value keyword_token_; | 674 Token::Value keyword_token_; |
| 665 }; | 675 }; |
| 666 | 676 |
| 667 | 677 |
| 668 } } // namespace v8::internal | 678 } } // namespace v8::internal |
| 669 | 679 |
| 670 #endif // V8_SCANNER_BASE_H_ | 680 #endif // V8_SCANNER_BASE_H_ |
| OLD | NEW |