| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 part of scanner; | 5 part of scanner; |
| 6 | 6 |
| 7 abstract class Scanner { | 7 abstract class Scanner { |
| 8 Token tokenize(); | 8 Token tokenize(); |
| 9 } | 9 } |
| 10 | 10 |
| (...skipping 642 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 653 appendKeywordToken(state.keyword); | 653 appendKeywordToken(state.keyword); |
| 654 return next; | 654 return next; |
| 655 } else { | 655 } else { |
| 656 return tokenizeIdentifier(next, start, allowDollar); | 656 return tokenizeIdentifier(next, start, allowDollar); |
| 657 } | 657 } |
| 658 } | 658 } |
| 659 | 659 |
| 660 int tokenizeIdentifier(int next, int start, bool allowDollar) { | 660 int tokenizeIdentifier(int next, int start, bool allowDollar) { |
| 661 bool isAscii = true; | 661 bool isAscii = true; |
| 662 | 662 |
| 663 // TODO(aprelev@gmail.com): Remove deprecated Dynamic keyword support. | |
| 664 bool isDynamicBuiltIn = false; | |
| 665 | |
| 666 if (identical(next, $D)) { | |
| 667 next = advance(); | |
| 668 if (identical(next, $y)) { | |
| 669 next = advance(); | |
| 670 if (identical(next, $n)) { | |
| 671 next = advance(); | |
| 672 if (identical(next, $a)) { | |
| 673 next = advance(); | |
| 674 if (identical(next, $m)) { | |
| 675 next = advance(); | |
| 676 if (identical(next, $i)) { | |
| 677 next = advance(); | |
| 678 if (identical(next, $c)) { | |
| 679 isDynamicBuiltIn = true; | |
| 680 next = advance(); | |
| 681 } | |
| 682 } | |
| 683 } | |
| 684 } | |
| 685 } | |
| 686 } | |
| 687 } | |
| 688 | |
| 689 while (true) { | 663 while (true) { |
| 690 if (($a <= next && next <= $z) || | 664 if (($a <= next && next <= $z) || |
| 691 ($A <= next && next <= $Z) || | 665 ($A <= next && next <= $Z) || |
| 692 ($0 <= next && next <= $9) || | 666 ($0 <= next && next <= $9) || |
| 693 identical(next, $_) || | 667 identical(next, $_) || |
| 694 (identical(next, $$) && allowDollar)) { | 668 (identical(next, $$) && allowDollar)) { |
| 695 isDynamicBuiltIn = false; | |
| 696 next = advance(); | 669 next = advance(); |
| 697 } else if ((next < 128) || (identical(next, $NBSP))) { | 670 } else if ((next < 128) || (identical(next, $NBSP))) { |
| 698 // Identifier ends here. | 671 // Identifier ends here. |
| 699 if (start == byteOffset) { | 672 if (start == byteOffset) { |
| 700 return error(const SourceString("expected identifier")); | 673 return error(const SourceString("expected identifier")); |
| 701 } else if (isDynamicBuiltIn) { | |
| 702 appendKeywordToken(Keyword.DYNAMIC_DEPRECATED); | |
| 703 } else if (isAscii) { | 674 } else if (isAscii) { |
| 704 appendByteStringToken(IDENTIFIER_INFO, asciiString(start, 0)); | 675 appendByteStringToken(IDENTIFIER_INFO, asciiString(start, 0)); |
| 705 } else { | 676 } else { |
| 706 appendByteStringToken(BAD_INPUT_INFO, utf8String(start, -1)); | 677 appendByteStringToken(BAD_INPUT_INFO, utf8String(start, -1)); |
| 707 } | 678 } |
| 708 return next; | 679 return next; |
| 709 } else { | 680 } else { |
| 710 isDynamicBuiltIn = false; | |
| 711 int nonAsciiStart = byteOffset; | 681 int nonAsciiStart = byteOffset; |
| 712 do { | 682 do { |
| 713 next = nextByte(); | 683 next = nextByte(); |
| 714 if (identical(next, $NBSP)) break; | 684 if (identical(next, $NBSP)) break; |
| 715 } while (next > 127); | 685 } while (next > 127); |
| 716 String string = utf8String(nonAsciiStart, -1).slowToString(); | 686 String string = utf8String(nonAsciiStart, -1).slowToString(); |
| 717 isAscii = false; | 687 isAscii = false; |
| 718 int byteLength = nonAsciiStart - byteOffset; | 688 int byteLength = nonAsciiStart - byteOffset; |
| 719 addToCharOffset(string.length - byteLength); | 689 addToCharOffset(string.length - byteLength); |
| 720 } | 690 } |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 866 next = advance(); | 836 next = advance(); |
| 867 } | 837 } |
| 868 return error(const SourceString("unterminated string literal")); | 838 return error(const SourceString("unterminated string literal")); |
| 869 } | 839 } |
| 870 | 840 |
| 871 int error(SourceString message) { | 841 int error(SourceString message) { |
| 872 appendByteStringToken(BAD_INPUT_INFO, message); | 842 appendByteStringToken(BAD_INPUT_INFO, message); |
| 873 return advance(); // Ensure progress. | 843 return advance(); // Ensure progress. |
| 874 } | 844 } |
| 875 } | 845 } |
| OLD | NEW |