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 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
317 complete_ = true; | 317 complete_ = true; |
318 } | 318 } |
319 | 319 |
320 | 320 |
321 // ---------------------------------------------------------------------------- | 321 // ---------------------------------------------------------------------------- |
322 // V8JavaScriptScanner | 322 // V8JavaScriptScanner |
323 | 323 |
324 V8JavaScriptScanner::V8JavaScriptScanner() : JavaScriptScanner() { } | 324 V8JavaScriptScanner::V8JavaScriptScanner() : JavaScriptScanner() { } |
325 | 325 |
326 | 326 |
327 void V8JavaScriptScanner::Initialize(UC16CharacterStream* source, | 327 void V8JavaScriptScanner::Initialize(UC16CharacterStream* source) { |
328 int literal_flags) { | |
329 source_ = source; | 328 source_ = source; |
330 literal_flags_ = literal_flags | kLiteralIdentifier; | |
331 // Need to capture identifiers in order to recognize "get" and "set" | 329 // Need to capture identifiers in order to recognize "get" and "set" |
332 // in object literals. | 330 // in object literals. |
333 Init(); | 331 Init(); |
334 // Skip initial whitespace allowing HTML comment ends just like | 332 // Skip initial whitespace allowing HTML comment ends just like |
335 // after a newline and scan first token. | 333 // after a newline and scan first token. |
336 has_line_terminator_before_next_ = true; | 334 has_line_terminator_before_next_ = true; |
337 SkipWhiteSpace(); | 335 SkipWhiteSpace(); |
338 Scan(); | 336 Scan(); |
339 } | 337 } |
340 | 338 |
(...skipping 29 matching lines...) Expand all Loading... |
370 int start_position = source_pos(); | 368 int start_position = source_pos(); |
371 // JSON WhiteSpace is tab, carrige-return, newline and space. | 369 // JSON WhiteSpace is tab, carrige-return, newline and space. |
372 while (c0_ == ' ' || c0_ == '\n' || c0_ == '\r' || c0_ == '\t') { | 370 while (c0_ == ' ' || c0_ == '\n' || c0_ == '\r' || c0_ == '\t') { |
373 Advance(); | 371 Advance(); |
374 } | 372 } |
375 return source_pos() != start_position; | 373 return source_pos() != start_position; |
376 } | 374 } |
377 | 375 |
378 | 376 |
379 void JsonScanner::ScanJson() { | 377 void JsonScanner::ScanJson() { |
380 next_.literal_chars = Vector<const char>(); | 378 next_.literal_chars = NULL; |
381 Token::Value token; | 379 Token::Value token; |
382 do { | 380 do { |
383 // Remember the position of the next token | 381 // Remember the position of the next token |
384 next_.location.beg_pos = source_pos(); | 382 next_.location.beg_pos = source_pos(); |
385 switch (c0_) { | 383 switch (c0_) { |
386 case '\t': | 384 case '\t': |
387 case '\r': | 385 case '\r': |
388 case '\n': | 386 case '\n': |
389 case ' ': | 387 case ' ': |
390 Advance(); | 388 Advance(); |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
558 text++; | 556 text++; |
559 } | 557 } |
560 if (ScannerConstants::kIsIdentifierPart.get(c0_)) return Token::ILLEGAL; | 558 if (ScannerConstants::kIsIdentifierPart.get(c0_)) return Token::ILLEGAL; |
561 literal.Complete(); | 559 literal.Complete(); |
562 return token; | 560 return token; |
563 } | 561 } |
564 | 562 |
565 | 563 |
566 | 564 |
567 } } // namespace v8::internal | 565 } } // namespace v8::internal |
OLD | NEW |