| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 // Features shared by parsing and pre-parsing scanners. | 5 // Features shared by parsing and pre-parsing scanners. |
| 6 | 6 |
| 7 #ifndef V8_SCANNER_H_ | 7 #ifndef V8_SCANNER_H_ |
| 8 #define V8_SCANNER_H_ | 8 #define V8_SCANNER_H_ |
| 9 | 9 |
| 10 #include "src/allocation.h" | 10 #include "src/allocation.h" |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 UnicodeCache() {} | 114 UnicodeCache() {} |
| 115 typedef unibrow::Utf8Decoder<512> Utf8Decoder; | 115 typedef unibrow::Utf8Decoder<512> Utf8Decoder; |
| 116 | 116 |
| 117 StaticResource<Utf8Decoder>* utf8_decoder() { | 117 StaticResource<Utf8Decoder>* utf8_decoder() { |
| 118 return &utf8_decoder_; | 118 return &utf8_decoder_; |
| 119 } | 119 } |
| 120 | 120 |
| 121 bool IsIdentifierStart(unibrow::uchar c) { return kIsIdentifierStart.get(c); } | 121 bool IsIdentifierStart(unibrow::uchar c) { return kIsIdentifierStart.get(c); } |
| 122 bool IsIdentifierPart(unibrow::uchar c) { return kIsIdentifierPart.get(c); } | 122 bool IsIdentifierPart(unibrow::uchar c) { return kIsIdentifierPart.get(c); } |
| 123 bool IsLineTerminator(unibrow::uchar c) { return kIsLineTerminator.get(c); } | 123 bool IsLineTerminator(unibrow::uchar c) { return kIsLineTerminator.get(c); } |
| 124 bool IsLineTerminatorSequence(unibrow::uchar c, unibrow::uchar next) { |
| 125 if (!IsLineTerminator(c)) return false; |
| 126 if (c == 0x000d && next == 0x000a) return false; // CR with following LF. |
| 127 return true; |
| 128 } |
| 129 |
| 124 bool IsWhiteSpace(unibrow::uchar c) { return kIsWhiteSpace.get(c); } | 130 bool IsWhiteSpace(unibrow::uchar c) { return kIsWhiteSpace.get(c); } |
| 125 bool IsWhiteSpaceOrLineTerminator(unibrow::uchar c) { | 131 bool IsWhiteSpaceOrLineTerminator(unibrow::uchar c) { |
| 126 return kIsWhiteSpaceOrLineTerminator.get(c); | 132 return kIsWhiteSpaceOrLineTerminator.get(c); |
| 127 } | 133 } |
| 128 | 134 |
| 129 private: | 135 private: |
| 130 unibrow::Predicate<IdentifierStart, 128> kIsIdentifierStart; | 136 unibrow::Predicate<IdentifierStart, 128> kIsIdentifierStart; |
| 131 unibrow::Predicate<IdentifierPart, 128> kIsIdentifierPart; | 137 unibrow::Predicate<IdentifierPart, 128> kIsIdentifierPart; |
| 132 unibrow::Predicate<unibrow::LineTerminator, 128> kIsLineTerminator; | 138 unibrow::Predicate<unibrow::LineTerminator, 128> kIsLineTerminator; |
| 133 unibrow::Predicate<WhiteSpace, 128> kIsWhiteSpace; | 139 unibrow::Predicate<WhiteSpace, 128> kIsWhiteSpace; |
| (...skipping 603 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 737 bool harmony_classes_; | 743 bool harmony_classes_; |
| 738 // Whether we scan TEMPLATE_SPAN and TEMPLATE_TAIL | 744 // Whether we scan TEMPLATE_SPAN and TEMPLATE_TAIL |
| 739 bool harmony_templates_; | 745 bool harmony_templates_; |
| 740 // Whether we allow \u{xxxxx}. | 746 // Whether we allow \u{xxxxx}. |
| 741 bool harmony_unicode_; | 747 bool harmony_unicode_; |
| 742 }; | 748 }; |
| 743 | 749 |
| 744 } } // namespace v8::internal | 750 } } // namespace v8::internal |
| 745 | 751 |
| 746 #endif // V8_SCANNER_H_ | 752 #endif // V8_SCANNER_H_ |
| OLD | NEW |