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 #include "src/parsing/scanner.h" | 7 #include "src/parsing/scanner.h" |
8 | 8 |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 | 10 |
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
350 TryToParseSourceURLComment(); | 350 TryToParseSourceURLComment(); |
351 while (c0_ >= 0 && !unicode_cache_->IsLineTerminator(c0_)) { | 351 while (c0_ >= 0 && !unicode_cache_->IsLineTerminator(c0_)) { |
352 Advance(); | 352 Advance(); |
353 } | 353 } |
354 | 354 |
355 return Token::WHITESPACE; | 355 return Token::WHITESPACE; |
356 } | 356 } |
357 | 357 |
358 | 358 |
359 void Scanner::TryToParseSourceURLComment() { | 359 void Scanner::TryToParseSourceURLComment() { |
360 // Magic comments are of the form: //[#]\s<name>=\s*<value>\s*.* and this | 360 // Magic comments are of the form: //[#@]\s<name>=\s*<value>\s*.* and this |
361 // function will just return if it cannot parse a magic comment. | 361 // function will just return if it cannot parse a magic comment. |
362 if (c0_ < 0 || !unicode_cache_->IsWhiteSpace(c0_)) return; | 362 if (c0_ < 0 || !unicode_cache_->IsWhiteSpace(c0_)) return; |
363 Advance(); | 363 Advance(); |
364 LiteralBuffer name; | 364 LiteralBuffer name; |
365 while (c0_ >= 0 && !unicode_cache_->IsWhiteSpaceOrLineTerminator(c0_) && | 365 while (c0_ >= 0 && !unicode_cache_->IsWhiteSpaceOrLineTerminator(c0_) && |
366 c0_ != '=') { | 366 c0_ != '=') { |
367 name.AddChar(c0_); | 367 name.AddChar(c0_); |
368 Advance(); | 368 Advance(); |
369 } | 369 } |
370 if (!name.is_one_byte()) return; | 370 if (!name.is_one_byte()) return; |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
571 case '%': | 571 case '%': |
572 // % %= | 572 // % %= |
573 token = Select('=', Token::ASSIGN_MOD, Token::MOD); | 573 token = Select('=', Token::ASSIGN_MOD, Token::MOD); |
574 break; | 574 break; |
575 | 575 |
576 case '/': | 576 case '/': |
577 // / // /* /= | 577 // / // /* /= |
578 Advance(); | 578 Advance(); |
579 if (c0_ == '/') { | 579 if (c0_ == '/') { |
580 Advance(); | 580 Advance(); |
581 if (c0_ == '#') { | 581 if (c0_ == '#' || c0_ == '@') { |
582 Advance(); | 582 Advance(); |
583 token = SkipSourceURLComment(); | 583 token = SkipSourceURLComment(); |
584 } else { | 584 } else { |
585 PushBack(c0_); | 585 PushBack(c0_); |
586 token = SkipSingleLineComment(); | 586 token = SkipSingleLineComment(); |
587 } | 587 } |
588 } else if (c0_ == '*') { | 588 } else if (c0_ == '*') { |
589 token = SkipMultiLineComment(); | 589 token = SkipMultiLineComment(); |
590 } else if (c0_ == '=') { | 590 } else if (c0_ == '=') { |
591 token = Select(Token::ASSIGN_DIV); | 591 token = Select(Token::ASSIGN_DIV); |
(...skipping 1078 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1670 backing_store_.Add(static_cast<uint8_t>((one_byte_length >> 7) | 0x80u)); | 1670 backing_store_.Add(static_cast<uint8_t>((one_byte_length >> 7) | 0x80u)); |
1671 } | 1671 } |
1672 backing_store_.Add(static_cast<uint8_t>(one_byte_length & 0x7f)); | 1672 backing_store_.Add(static_cast<uint8_t>(one_byte_length & 0x7f)); |
1673 | 1673 |
1674 backing_store_.AddBlock(bytes); | 1674 backing_store_.AddBlock(bytes); |
1675 return backing_store_.EndSequence().start(); | 1675 return backing_store_.EndSequence().start(); |
1676 } | 1676 } |
1677 | 1677 |
1678 } // namespace internal | 1678 } // namespace internal |
1679 } // namespace v8 | 1679 } // namespace v8 |
OLD | NEW |