| 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 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 const uc16* buffer_end_; | 138 const uc16* buffer_end_; |
| 139 unsigned pos_; | 139 unsigned pos_; |
| 140 }; | 140 }; |
| 141 | 141 |
| 142 | 142 |
| 143 class UnicodeCache { | 143 class UnicodeCache { |
| 144 // --------------------------------------------------------------------- | 144 // --------------------------------------------------------------------- |
| 145 // Caching predicates used by scanners. | 145 // Caching predicates used by scanners. |
| 146 public: | 146 public: |
| 147 UnicodeCache() {} | 147 UnicodeCache() {} |
| 148 typedef unibrow::Utf8InputBuffer<1024> Utf8Decoder; | 148 typedef unibrow::Utf8Decoder<512> Utf8Decoder; |
| 149 | 149 |
| 150 StaticResource<Utf8Decoder>* utf8_decoder() { | 150 StaticResource<Utf8Decoder>* utf8_decoder() { |
| 151 return &utf8_decoder_; | 151 return &utf8_decoder_; |
| 152 } | 152 } |
| 153 | 153 |
| 154 bool IsIdentifierStart(unibrow::uchar c) { return kIsIdentifierStart.get(c); } | 154 bool IsIdentifierStart(unibrow::uchar c) { return kIsIdentifierStart.get(c); } |
| 155 bool IsIdentifierPart(unibrow::uchar c) { return kIsIdentifierPart.get(c); } | 155 bool IsIdentifierPart(unibrow::uchar c) { return kIsIdentifierPart.get(c); } |
| 156 bool IsLineTerminator(unibrow::uchar c) { return kIsLineTerminator.get(c); } | 156 bool IsLineTerminator(unibrow::uchar c) { return kIsLineTerminator.get(c); } |
| 157 bool IsWhiteSpace(unibrow::uchar c) { return kIsWhiteSpace.get(c); } | 157 bool IsWhiteSpace(unibrow::uchar c) { return kIsWhiteSpace.get(c); } |
| 158 | 158 |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 308 | 308 |
| 309 static Location invalid() { return Location(-1, -1); } | 309 static Location invalid() { return Location(-1, -1); } |
| 310 | 310 |
| 311 int beg_pos; | 311 int beg_pos; |
| 312 int end_pos; | 312 int end_pos; |
| 313 }; | 313 }; |
| 314 | 314 |
| 315 // -1 is outside of the range of any real source code. | 315 // -1 is outside of the range of any real source code. |
| 316 static const int kNoOctalLocation = -1; | 316 static const int kNoOctalLocation = -1; |
| 317 | 317 |
| 318 typedef unibrow::Utf8InputBuffer<1024> Utf8Decoder; | |
| 319 | |
| 320 explicit Scanner(UnicodeCache* scanner_contants); | 318 explicit Scanner(UnicodeCache* scanner_contants); |
| 321 | 319 |
| 322 void Initialize(Utf16CharacterStream* source); | 320 void Initialize(Utf16CharacterStream* source); |
| 323 | 321 |
| 324 // Returns the next token and advances input. | 322 // Returns the next token and advances input. |
| 325 Token::Value Next(); | 323 Token::Value Next(); |
| 326 // Returns the current token again. | 324 // Returns the current token again. |
| 327 Token::Value current_token() { return current_.token; } | 325 Token::Value current_token() { return current_.token; } |
| 328 // Returns the location information for the current token | 326 // Returns the location information for the current token |
| 329 // (the token last returned by Next()). | 327 // (the token last returned by Next()). |
| (...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 567 bool has_multiline_comment_before_next_; | 565 bool has_multiline_comment_before_next_; |
| 568 // Whether we scan 'let' as a keyword for harmony block-scoped let bindings. | 566 // Whether we scan 'let' as a keyword for harmony block-scoped let bindings. |
| 569 bool harmony_scoping_; | 567 bool harmony_scoping_; |
| 570 // Whether we scan 'module', 'import', 'export' as keywords. | 568 // Whether we scan 'module', 'import', 'export' as keywords. |
| 571 bool harmony_modules_; | 569 bool harmony_modules_; |
| 572 }; | 570 }; |
| 573 | 571 |
| 574 } } // namespace v8::internal | 572 } } // namespace v8::internal |
| 575 | 573 |
| 576 #endif // V8_SCANNER_H_ | 574 #endif // V8_SCANNER_H_ |
| OLD | NEW |