OLD | NEW |
1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 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 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
244 bool ScanRegExpFlags(); | 244 bool ScanRegExpFlags(); |
245 | 245 |
246 // Seek forward to the given position. This operation does not | 246 // Seek forward to the given position. This operation does not |
247 // work in general, for instance when there are pushed back | 247 // work in general, for instance when there are pushed back |
248 // characters, but works for seeking forward until simple delimiter | 248 // characters, but works for seeking forward until simple delimiter |
249 // tokens, which is what it is used for. | 249 // tokens, which is what it is used for. |
250 void SeekForward(int pos); | 250 void SeekForward(int pos); |
251 | 251 |
252 bool stack_overflow() { return stack_overflow_; } | 252 bool stack_overflow() { return stack_overflow_; } |
253 | 253 |
254 static StaticResource<Utf8Decoder>* utf8_decoder() { return &utf8_decoder_; } | |
255 | |
256 // Tells whether the buffer contains an identifier (no escapes). | 254 // Tells whether the buffer contains an identifier (no escapes). |
257 // Used for checking if a property name is an identifier. | 255 // Used for checking if a property name is an identifier. |
258 static bool IsIdentifier(unibrow::CharacterStream* buffer); | 256 static bool IsIdentifier(unibrow::CharacterStream* buffer); |
259 | 257 |
260 static unibrow::Predicate<IdentifierStart, 128> kIsIdentifierStart; | |
261 static unibrow::Predicate<IdentifierPart, 128> kIsIdentifierPart; | |
262 static unibrow::Predicate<unibrow::LineTerminator, 128> kIsLineTerminator; | |
263 static unibrow::Predicate<unibrow::WhiteSpace, 128> kIsWhiteSpace; | |
264 | |
265 static const int kCharacterLookaheadBufferSize = 1; | 258 static const int kCharacterLookaheadBufferSize = 1; |
266 static const int kNoEndPosition = 1; | 259 static const int kNoEndPosition = 1; |
267 | 260 |
268 private: | 261 private: |
269 // The current and look-ahead token. | 262 // The current and look-ahead token. |
270 struct TokenDesc { | 263 struct TokenDesc { |
271 Token::Value token; | 264 Token::Value token; |
272 Location location; | 265 Location location; |
273 Vector<const char> literal_chars; | 266 Vector<const char> literal_chars; |
274 }; | 267 }; |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
384 | 377 |
385 // Used to convert the source string into a character stream when a stream | 378 // Used to convert the source string into a character stream when a stream |
386 // is not passed to the scanner. | 379 // is not passed to the scanner. |
387 SafeStringInputBuffer safe_string_input_buffer_; | 380 SafeStringInputBuffer safe_string_input_buffer_; |
388 | 381 |
389 // Buffer to hold literal values (identifiers, strings, numbers) | 382 // Buffer to hold literal values (identifiers, strings, numbers) |
390 // using '\x00'-terminated UTF-8 encoding. Handles allocation internally. | 383 // using '\x00'-terminated UTF-8 encoding. Handles allocation internally. |
391 UTF8Buffer literal_buffer_; | 384 UTF8Buffer literal_buffer_; |
392 | 385 |
393 bool stack_overflow_; | 386 bool stack_overflow_; |
394 static StaticResource<Utf8Decoder> utf8_decoder_; | |
395 | 387 |
396 // One Unicode character look-ahead; c0_ < 0 at the end of the input. | 388 // One Unicode character look-ahead; c0_ < 0 at the end of the input. |
397 uc32 c0_; | 389 uc32 c0_; |
398 }; | 390 }; |
399 | 391 |
400 } } // namespace v8::internal | 392 } } // namespace v8::internal |
401 | 393 |
402 #endif // V8_SCANNER_H_ | 394 #endif // V8_SCANNER_H_ |
OLD | NEW |