| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 library engine.scanner; | 5 library engine.scanner; |
| 6 | 6 |
| 7 import 'dart:collection'; | 7 import 'dart:collection'; |
| 8 | 8 |
| 9 import 'error.dart'; | 9 import 'error.dart'; |
| 10 import 'java_engine.dart'; | 10 import 'java_engine.dart'; |
| (...skipping 705 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 716 * empty. | 716 * empty. |
| 717 */ | 717 */ |
| 718 int _stackEnd = -1; | 718 int _stackEnd = -1; |
| 719 | 719 |
| 720 /** | 720 /** |
| 721 * A flag indicating whether any unmatched groups were found during the parse. | 721 * A flag indicating whether any unmatched groups were found during the parse. |
| 722 */ | 722 */ |
| 723 bool _hasUnmatchedGroups = false; | 723 bool _hasUnmatchedGroups = false; |
| 724 | 724 |
| 725 /** | 725 /** |
| 726 * A flag indicating whether null-aware operators ('?.', '??', and '??=') |
| 727 * should be tokenized. |
| 728 */ |
| 729 bool enableNullAwareOperators = false; |
| 730 |
| 731 /** |
| 726 * Initialize a newly created scanner to scan characters from the given | 732 * Initialize a newly created scanner to scan characters from the given |
| 727 * [source]. The given character [_reader] will be used to read the characters | 733 * [source]. The given character [_reader] will be used to read the characters |
| 728 * in the source. The given [_errorListener] will be informed of any errors | 734 * in the source. The given [_errorListener] will be informed of any errors |
| 729 * that are found. | 735 * that are found. |
| 730 */ | 736 */ |
| 731 Scanner(this.source, this._reader, this._errorListener) { | 737 Scanner(this.source, this._reader, this._errorListener) { |
| 732 _tokens = new Token(TokenType.EOF, -1); | 738 _tokens = new Token(TokenType.EOF, -1); |
| 733 _tokens.setNext(_tokens); | 739 _tokens.setNext(_tokens); |
| 734 _tail = _tokens; | 740 _tail = _tokens; |
| 735 _tokenStart = -1; | 741 _tokenStart = -1; |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 770 * should not normally be used because it will fail to correctly associate any | 776 * should not normally be used because it will fail to correctly associate any |
| 771 * comments with the token being passed in. | 777 * comments with the token being passed in. |
| 772 */ | 778 */ |
| 773 void appendToken(Token token) { | 779 void appendToken(Token token) { |
| 774 _tail = _tail.setNext(token); | 780 _tail = _tail.setNext(token); |
| 775 } | 781 } |
| 776 | 782 |
| 777 int bigSwitch(int next) { | 783 int bigSwitch(int next) { |
| 778 _beginToken(); | 784 _beginToken(); |
| 779 if (next == 0xD) { | 785 if (next == 0xD) { |
| 786 // '\r' |
| 780 next = _reader.advance(); | 787 next = _reader.advance(); |
| 781 if (next == 0xA) { | 788 if (next == 0xA) { |
| 789 // '\n' |
| 782 next = _reader.advance(); | 790 next = _reader.advance(); |
| 783 } | 791 } |
| 784 recordStartOfLine(); | 792 recordStartOfLine(); |
| 785 return next; | 793 return next; |
| 786 } else if (next == 0xA) { | 794 } else if (next == 0xA) { |
| 795 // '\n' |
| 787 next = _reader.advance(); | 796 next = _reader.advance(); |
| 788 recordStartOfLine(); | 797 recordStartOfLine(); |
| 789 return next; | 798 return next; |
| 790 } else if (next == 0x9 || next == 0x20) { | 799 } else if (next == 0x9 || next == 0x20) { |
| 800 // '\t' || ' ' |
| 791 return _reader.advance(); | 801 return _reader.advance(); |
| 792 } | 802 } |
| 793 if (next == 0x72) { | 803 if (next == 0x72) { |
| 804 // 'r' |
| 794 int peek = _reader.peek(); | 805 int peek = _reader.peek(); |
| 795 if (peek == 0x22 || peek == 0x27) { | 806 if (peek == 0x22 || peek == 0x27) { |
| 807 // '"' || "'" |
| 796 int start = _reader.offset; | 808 int start = _reader.offset; |
| 797 return _tokenizeString(_reader.advance(), start, true); | 809 return _tokenizeString(_reader.advance(), start, true); |
| 798 } | 810 } |
| 799 } | 811 } |
| 800 if (0x61 <= next && next <= 0x7A) { | 812 if (0x61 <= next && next <= 0x7A) { |
| 813 // 'a'-'z' |
| 801 return _tokenizeKeywordOrIdentifier(next, true); | 814 return _tokenizeKeywordOrIdentifier(next, true); |
| 802 } | 815 } |
| 803 if ((0x41 <= next && next <= 0x5A) || next == 0x5F || next == 0x24) { | 816 if ((0x41 <= next && next <= 0x5A) || next == 0x5F || next == 0x24) { |
| 817 // 'A'-'Z' || '_' || '$' |
| 804 return _tokenizeIdentifier(next, _reader.offset, true); | 818 return _tokenizeIdentifier(next, _reader.offset, true); |
| 805 } | 819 } |
| 806 if (next == 0x3C) { | 820 if (next == 0x3C) { |
| 821 // '<' |
| 807 return _tokenizeLessThan(next); | 822 return _tokenizeLessThan(next); |
| 808 } | 823 } |
| 809 if (next == 0x3E) { | 824 if (next == 0x3E) { |
| 825 // '>' |
| 810 return _tokenizeGreaterThan(next); | 826 return _tokenizeGreaterThan(next); |
| 811 } | 827 } |
| 812 if (next == 0x3D) { | 828 if (next == 0x3D) { |
| 829 // '=' |
| 813 return _tokenizeEquals(next); | 830 return _tokenizeEquals(next); |
| 814 } | 831 } |
| 815 if (next == 0x21) { | 832 if (next == 0x21) { |
| 833 // '!' |
| 816 return _tokenizeExclamation(next); | 834 return _tokenizeExclamation(next); |
| 817 } | 835 } |
| 818 if (next == 0x2B) { | 836 if (next == 0x2B) { |
| 837 // '+' |
| 819 return _tokenizePlus(next); | 838 return _tokenizePlus(next); |
| 820 } | 839 } |
| 821 if (next == 0x2D) { | 840 if (next == 0x2D) { |
| 841 // '-' |
| 822 return _tokenizeMinus(next); | 842 return _tokenizeMinus(next); |
| 823 } | 843 } |
| 824 if (next == 0x2A) { | 844 if (next == 0x2A) { |
| 845 // '*' |
| 825 return _tokenizeMultiply(next); | 846 return _tokenizeMultiply(next); |
| 826 } | 847 } |
| 827 if (next == 0x25) { | 848 if (next == 0x25) { |
| 849 // '%' |
| 828 return _tokenizePercent(next); | 850 return _tokenizePercent(next); |
| 829 } | 851 } |
| 830 if (next == 0x26) { | 852 if (next == 0x26) { |
| 853 // '&' |
| 831 return _tokenizeAmpersand(next); | 854 return _tokenizeAmpersand(next); |
| 832 } | 855 } |
| 833 if (next == 0x7C) { | 856 if (next == 0x7C) { |
| 857 // '|' |
| 834 return _tokenizeBar(next); | 858 return _tokenizeBar(next); |
| 835 } | 859 } |
| 836 if (next == 0x5E) { | 860 if (next == 0x5E) { |
| 861 // '^' |
| 837 return _tokenizeCaret(next); | 862 return _tokenizeCaret(next); |
| 838 } | 863 } |
| 839 if (next == 0x5B) { | 864 if (next == 0x5B) { |
| 865 // '[' |
| 840 return _tokenizeOpenSquareBracket(next); | 866 return _tokenizeOpenSquareBracket(next); |
| 841 } | 867 } |
| 842 if (next == 0x7E) { | 868 if (next == 0x7E) { |
| 869 // '~' |
| 843 return _tokenizeTilde(next); | 870 return _tokenizeTilde(next); |
| 844 } | 871 } |
| 845 if (next == 0x5C) { | 872 if (next == 0x5C) { |
| 873 // '\\' |
| 846 _appendTokenOfType(TokenType.BACKSLASH); | 874 _appendTokenOfType(TokenType.BACKSLASH); |
| 847 return _reader.advance(); | 875 return _reader.advance(); |
| 848 } | 876 } |
| 849 if (next == 0x23) { | 877 if (next == 0x23) { |
| 878 // '#' |
| 850 return _tokenizeTag(next); | 879 return _tokenizeTag(next); |
| 851 } | 880 } |
| 852 if (next == 0x28) { | 881 if (next == 0x28) { |
| 882 // '(' |
| 853 _appendBeginToken(TokenType.OPEN_PAREN); | 883 _appendBeginToken(TokenType.OPEN_PAREN); |
| 854 return _reader.advance(); | 884 return _reader.advance(); |
| 855 } | 885 } |
| 856 if (next == 0x29) { | 886 if (next == 0x29) { |
| 887 // ')' |
| 857 _appendEndToken(TokenType.CLOSE_PAREN, TokenType.OPEN_PAREN); | 888 _appendEndToken(TokenType.CLOSE_PAREN, TokenType.OPEN_PAREN); |
| 858 return _reader.advance(); | 889 return _reader.advance(); |
| 859 } | 890 } |
| 860 if (next == 0x2C) { | 891 if (next == 0x2C) { |
| 892 // ',' |
| 861 _appendTokenOfType(TokenType.COMMA); | 893 _appendTokenOfType(TokenType.COMMA); |
| 862 return _reader.advance(); | 894 return _reader.advance(); |
| 863 } | 895 } |
| 864 if (next == 0x3A) { | 896 if (next == 0x3A) { |
| 897 // ':' |
| 865 _appendTokenOfType(TokenType.COLON); | 898 _appendTokenOfType(TokenType.COLON); |
| 866 return _reader.advance(); | 899 return _reader.advance(); |
| 867 } | 900 } |
| 868 if (next == 0x3B) { | 901 if (next == 0x3B) { |
| 902 // ';' |
| 869 _appendTokenOfType(TokenType.SEMICOLON); | 903 _appendTokenOfType(TokenType.SEMICOLON); |
| 870 return _reader.advance(); | 904 return _reader.advance(); |
| 871 } | 905 } |
| 872 if (next == 0x3F) { | 906 if (next == 0x3F) { |
| 873 _appendTokenOfType(TokenType.QUESTION); | 907 // '?' |
| 874 return _reader.advance(); | 908 return _tokenizeQuestion(); |
| 875 } | 909 } |
| 876 if (next == 0x5D) { | 910 if (next == 0x5D) { |
| 911 // ']' |
| 877 _appendEndToken( | 912 _appendEndToken( |
| 878 TokenType.CLOSE_SQUARE_BRACKET, TokenType.OPEN_SQUARE_BRACKET); | 913 TokenType.CLOSE_SQUARE_BRACKET, TokenType.OPEN_SQUARE_BRACKET); |
| 879 return _reader.advance(); | 914 return _reader.advance(); |
| 880 } | 915 } |
| 881 if (next == 0x60) { | 916 if (next == 0x60) { |
| 917 // '`' |
| 882 _appendTokenOfType(TokenType.BACKPING); | 918 _appendTokenOfType(TokenType.BACKPING); |
| 883 return _reader.advance(); | 919 return _reader.advance(); |
| 884 } | 920 } |
| 885 if (next == 0x7B) { | 921 if (next == 0x7B) { |
| 922 // '{' |
| 886 _appendBeginToken(TokenType.OPEN_CURLY_BRACKET); | 923 _appendBeginToken(TokenType.OPEN_CURLY_BRACKET); |
| 887 return _reader.advance(); | 924 return _reader.advance(); |
| 888 } | 925 } |
| 889 if (next == 0x7D) { | 926 if (next == 0x7D) { |
| 927 // '}' |
| 890 _appendEndToken( | 928 _appendEndToken( |
| 891 TokenType.CLOSE_CURLY_BRACKET, TokenType.OPEN_CURLY_BRACKET); | 929 TokenType.CLOSE_CURLY_BRACKET, TokenType.OPEN_CURLY_BRACKET); |
| 892 return _reader.advance(); | 930 return _reader.advance(); |
| 893 } | 931 } |
| 894 if (next == 0x2F) { | 932 if (next == 0x2F) { |
| 933 // '/' |
| 895 return _tokenizeSlashOrComment(next); | 934 return _tokenizeSlashOrComment(next); |
| 896 } | 935 } |
| 897 if (next == 0x40) { | 936 if (next == 0x40) { |
| 937 // '@' |
| 898 _appendTokenOfType(TokenType.AT); | 938 _appendTokenOfType(TokenType.AT); |
| 899 return _reader.advance(); | 939 return _reader.advance(); |
| 900 } | 940 } |
| 901 if (next == 0x22 || next == 0x27) { | 941 if (next == 0x22 || next == 0x27) { |
| 942 // '"' || "'" |
| 902 return _tokenizeString(next, _reader.offset, false); | 943 return _tokenizeString(next, _reader.offset, false); |
| 903 } | 944 } |
| 904 if (next == 0x2E) { | 945 if (next == 0x2E) { |
| 946 // '.' |
| 905 return _tokenizeDotOrNumber(next); | 947 return _tokenizeDotOrNumber(next); |
| 906 } | 948 } |
| 907 if (next == 0x30) { | 949 if (next == 0x30) { |
| 950 // '0' |
| 908 return _tokenizeHexOrNumber(next); | 951 return _tokenizeHexOrNumber(next); |
| 909 } | 952 } |
| 910 if (0x31 <= next && next <= 0x39) { | 953 if (0x31 <= next && next <= 0x39) { |
| 954 // '1'-'9' |
| 911 return _tokenizeNumber(next); | 955 return _tokenizeNumber(next); |
| 912 } | 956 } |
| 913 if (next == -1) { | 957 if (next == -1) { |
| 958 // EOF |
| 914 return -1; | 959 return -1; |
| 915 } | 960 } |
| 916 _reportError(ScannerErrorCode.ILLEGAL_CHARACTER, [next]); | 961 _reportError(ScannerErrorCode.ILLEGAL_CHARACTER, [next]); |
| 917 return _reader.advance(); | 962 return _reader.advance(); |
| 918 } | 963 } |
| 919 | 964 |
| 920 /** | 965 /** |
| 921 * Record the fact that we are at the beginning of a new line in the source. | 966 * Record the fact that we are at the beginning of a new line in the source. |
| 922 */ | 967 */ |
| 923 void recordStartOfLine() { | 968 void recordStartOfLine() { |
| (...skipping 685 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1609 return _reader.advance(); | 1654 return _reader.advance(); |
| 1610 } else if (0x3D == next) { | 1655 } else if (0x3D == next) { |
| 1611 _appendTokenOfType(TokenType.PLUS_EQ); | 1656 _appendTokenOfType(TokenType.PLUS_EQ); |
| 1612 return _reader.advance(); | 1657 return _reader.advance(); |
| 1613 } else { | 1658 } else { |
| 1614 _appendTokenOfType(TokenType.PLUS); | 1659 _appendTokenOfType(TokenType.PLUS); |
| 1615 return next; | 1660 return next; |
| 1616 } | 1661 } |
| 1617 } | 1662 } |
| 1618 | 1663 |
| 1664 int _tokenizeQuestion() { |
| 1665 // ? ?. ?? ??= |
| 1666 int next = _reader.advance(); |
| 1667 if (enableNullAwareOperators && next == 0x2E) { |
| 1668 // '.' |
| 1669 _appendTokenOfType(TokenType.QUESTION_PERIOD); |
| 1670 return _reader.advance(); |
| 1671 } else if (enableNullAwareOperators && next == 0x3F) { |
| 1672 // '?' |
| 1673 next = _reader.advance(); |
| 1674 if (next == 0x3D) { |
| 1675 // '=' |
| 1676 _appendTokenOfType(TokenType.QUESTION_QUESTION_EQ); |
| 1677 return _reader.advance(); |
| 1678 } else { |
| 1679 _appendTokenOfType(TokenType.QUESTION_QUESTION); |
| 1680 return next; |
| 1681 } |
| 1682 } else { |
| 1683 _appendTokenOfType(TokenType.QUESTION); |
| 1684 return next; |
| 1685 } |
| 1686 } |
| 1687 |
| 1619 int _tokenizeSingleLineComment(int next) { | 1688 int _tokenizeSingleLineComment(int next) { |
| 1620 while (true) { | 1689 while (true) { |
| 1621 next = _reader.advance(); | 1690 next = _reader.advance(); |
| 1622 if (-1 == next) { | 1691 if (-1 == next) { |
| 1623 _appendCommentToken( | 1692 _appendCommentToken( |
| 1624 TokenType.SINGLE_LINE_COMMENT, _reader.getString(_tokenStart, 0)); | 1693 TokenType.SINGLE_LINE_COMMENT, _reader.getString(_tokenStart, 0)); |
| 1625 return next; | 1694 return next; |
| 1626 } else if (0xA == next || 0xD == next) { | 1695 } else if (0xA == next || 0xD == next) { |
| 1627 _appendCommentToken( | 1696 _appendCommentToken( |
| 1628 TokenType.SINGLE_LINE_COMMENT, _reader.getString(_tokenStart, -1)); | 1697 TokenType.SINGLE_LINE_COMMENT, _reader.getString(_tokenStart, -1)); |
| (...skipping 484 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2113 /** | 2182 /** |
| 2114 * A value used to indicate that the token type is not part of any specific | 2183 * A value used to indicate that the token type is not part of any specific |
| 2115 * class of token. | 2184 * class of token. |
| 2116 */ | 2185 */ |
| 2117 static const TokenClass NO_CLASS = const TokenClass('NO_CLASS'); | 2186 static const TokenClass NO_CLASS = const TokenClass('NO_CLASS'); |
| 2118 | 2187 |
| 2119 /** | 2188 /** |
| 2120 * A value used to indicate that the token type is an additive operator. | 2189 * A value used to indicate that the token type is an additive operator. |
| 2121 */ | 2190 */ |
| 2122 static const TokenClass ADDITIVE_OPERATOR = | 2191 static const TokenClass ADDITIVE_OPERATOR = |
| 2123 const TokenClass('ADDITIVE_OPERATOR', 12); | 2192 const TokenClass('ADDITIVE_OPERATOR', 13); |
| 2124 | 2193 |
| 2125 /** | 2194 /** |
| 2126 * A value used to indicate that the token type is an assignment operator. | 2195 * A value used to indicate that the token type is an assignment operator. |
| 2127 */ | 2196 */ |
| 2128 static const TokenClass ASSIGNMENT_OPERATOR = | 2197 static const TokenClass ASSIGNMENT_OPERATOR = |
| 2129 const TokenClass('ASSIGNMENT_OPERATOR', 1); | 2198 const TokenClass('ASSIGNMENT_OPERATOR', 1); |
| 2130 | 2199 |
| 2131 /** | 2200 /** |
| 2132 * A value used to indicate that the token type is a bitwise-and operator. | 2201 * A value used to indicate that the token type is a bitwise-and operator. |
| 2133 */ | 2202 */ |
| 2134 static const TokenClass BITWISE_AND_OPERATOR = | 2203 static const TokenClass BITWISE_AND_OPERATOR = |
| 2135 const TokenClass('BITWISE_AND_OPERATOR', 10); | 2204 const TokenClass('BITWISE_AND_OPERATOR', 11); |
| 2136 | 2205 |
| 2137 /** | 2206 /** |
| 2138 * A value used to indicate that the token type is a bitwise-or operator. | 2207 * A value used to indicate that the token type is a bitwise-or operator. |
| 2139 */ | 2208 */ |
| 2140 static const TokenClass BITWISE_OR_OPERATOR = | 2209 static const TokenClass BITWISE_OR_OPERATOR = |
| 2141 const TokenClass('BITWISE_OR_OPERATOR', 8); | 2210 const TokenClass('BITWISE_OR_OPERATOR', 9); |
| 2142 | 2211 |
| 2143 /** | 2212 /** |
| 2144 * A value used to indicate that the token type is a bitwise-xor operator. | 2213 * A value used to indicate that the token type is a bitwise-xor operator. |
| 2145 */ | 2214 */ |
| 2146 static const TokenClass BITWISE_XOR_OPERATOR = | 2215 static const TokenClass BITWISE_XOR_OPERATOR = |
| 2147 const TokenClass('BITWISE_XOR_OPERATOR', 9); | 2216 const TokenClass('BITWISE_XOR_OPERATOR', 10); |
| 2148 | 2217 |
| 2149 /** | 2218 /** |
| 2150 * A value used to indicate that the token type is a cascade operator. | 2219 * A value used to indicate that the token type is a cascade operator. |
| 2151 */ | 2220 */ |
| 2152 static const TokenClass CASCADE_OPERATOR = | 2221 static const TokenClass CASCADE_OPERATOR = |
| 2153 const TokenClass('CASCADE_OPERATOR', 2); | 2222 const TokenClass('CASCADE_OPERATOR', 2); |
| 2154 | 2223 |
| 2155 /** | 2224 /** |
| 2156 * A value used to indicate that the token type is a conditional operator. | 2225 * A value used to indicate that the token type is a conditional operator. |
| 2157 */ | 2226 */ |
| 2158 static const TokenClass CONDITIONAL_OPERATOR = | 2227 static const TokenClass CONDITIONAL_OPERATOR = |
| 2159 const TokenClass('CONDITIONAL_OPERATOR', 3); | 2228 const TokenClass('CONDITIONAL_OPERATOR', 3); |
| 2160 | 2229 |
| 2161 /** | 2230 /** |
| 2162 * A value used to indicate that the token type is an equality operator. | 2231 * A value used to indicate that the token type is an equality operator. |
| 2163 */ | 2232 */ |
| 2164 static const TokenClass EQUALITY_OPERATOR = | 2233 static const TokenClass EQUALITY_OPERATOR = |
| 2165 const TokenClass('EQUALITY_OPERATOR', 6); | 2234 const TokenClass('EQUALITY_OPERATOR', 7); |
| 2235 |
| 2236 /** |
| 2237 * A value used to indicate that the token type is an if-null operator. |
| 2238 */ |
| 2239 static const TokenClass IF_NULL_OPERATOR = |
| 2240 const TokenClass('IF_NULL_OPERATOR', 4); |
| 2166 | 2241 |
| 2167 /** | 2242 /** |
| 2168 * A value used to indicate that the token type is a logical-and operator. | 2243 * A value used to indicate that the token type is a logical-and operator. |
| 2169 */ | 2244 */ |
| 2170 static const TokenClass LOGICAL_AND_OPERATOR = | 2245 static const TokenClass LOGICAL_AND_OPERATOR = |
| 2171 const TokenClass('LOGICAL_AND_OPERATOR', 5); | 2246 const TokenClass('LOGICAL_AND_OPERATOR', 6); |
| 2172 | 2247 |
| 2173 /** | 2248 /** |
| 2174 * A value used to indicate that the token type is a logical-or operator. | 2249 * A value used to indicate that the token type is a logical-or operator. |
| 2175 */ | 2250 */ |
| 2176 static const TokenClass LOGICAL_OR_OPERATOR = | 2251 static const TokenClass LOGICAL_OR_OPERATOR = |
| 2177 const TokenClass('LOGICAL_OR_OPERATOR', 4); | 2252 const TokenClass('LOGICAL_OR_OPERATOR', 5); |
| 2178 | 2253 |
| 2179 /** | 2254 /** |
| 2180 * A value used to indicate that the token type is a multiplicative operator. | 2255 * A value used to indicate that the token type is a multiplicative operator. |
| 2181 */ | 2256 */ |
| 2182 static const TokenClass MULTIPLICATIVE_OPERATOR = | 2257 static const TokenClass MULTIPLICATIVE_OPERATOR = |
| 2183 const TokenClass('MULTIPLICATIVE_OPERATOR', 13); | 2258 const TokenClass('MULTIPLICATIVE_OPERATOR', 14); |
| 2184 | 2259 |
| 2185 /** | 2260 /** |
| 2186 * A value used to indicate that the token type is a relational operator. | 2261 * A value used to indicate that the token type is a relational operator. |
| 2187 */ | 2262 */ |
| 2188 static const TokenClass RELATIONAL_OPERATOR = | 2263 static const TokenClass RELATIONAL_OPERATOR = |
| 2189 const TokenClass('RELATIONAL_OPERATOR', 7); | 2264 const TokenClass('RELATIONAL_OPERATOR', 8); |
| 2190 | 2265 |
| 2191 /** | 2266 /** |
| 2192 * A value used to indicate that the token type is a shift operator. | 2267 * A value used to indicate that the token type is a shift operator. |
| 2193 */ | 2268 */ |
| 2194 static const TokenClass SHIFT_OPERATOR = | 2269 static const TokenClass SHIFT_OPERATOR = |
| 2195 const TokenClass('SHIFT_OPERATOR', 11); | 2270 const TokenClass('SHIFT_OPERATOR', 12); |
| 2196 | 2271 |
| 2197 /** | 2272 /** |
| 2198 * A value used to indicate that the token type is a unary operator. | 2273 * A value used to indicate that the token type is a unary operator. |
| 2199 */ | 2274 */ |
| 2200 static const TokenClass UNARY_POSTFIX_OPERATOR = | 2275 static const TokenClass UNARY_POSTFIX_OPERATOR = |
| 2201 const TokenClass('UNARY_POSTFIX_OPERATOR', 15); | 2276 const TokenClass('UNARY_POSTFIX_OPERATOR', 16); |
| 2202 | 2277 |
| 2203 /** | 2278 /** |
| 2204 * A value used to indicate that the token type is a unary operator. | 2279 * A value used to indicate that the token type is a unary operator. |
| 2205 */ | 2280 */ |
| 2206 static const TokenClass UNARY_PREFIX_OPERATOR = | 2281 static const TokenClass UNARY_PREFIX_OPERATOR = |
| 2207 const TokenClass('UNARY_PREFIX_OPERATOR', 14); | 2282 const TokenClass('UNARY_PREFIX_OPERATOR', 15); |
| 2208 | 2283 |
| 2209 /** | 2284 /** |
| 2210 * The name of the token class. | 2285 * The name of the token class. |
| 2211 */ | 2286 */ |
| 2212 final String name; | 2287 final String name; |
| 2213 | 2288 |
| 2214 /** | 2289 /** |
| 2215 * The precedence of tokens of this class, or `0` if the such tokens do not | 2290 * The precedence of tokens of this class, or `0` if the such tokens do not |
| 2216 * represent an operator. | 2291 * represent an operator. |
| 2217 */ | 2292 */ |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2379 | 2454 |
| 2380 static const TokenType PLUS_EQ = | 2455 static const TokenType PLUS_EQ = |
| 2381 const TokenType('PLUS_EQ', TokenClass.ASSIGNMENT_OPERATOR, "+="); | 2456 const TokenType('PLUS_EQ', TokenClass.ASSIGNMENT_OPERATOR, "+="); |
| 2382 | 2457 |
| 2383 static const TokenType PLUS_PLUS = | 2458 static const TokenType PLUS_PLUS = |
| 2384 const TokenType('PLUS_PLUS', TokenClass.UNARY_PREFIX_OPERATOR, "++"); | 2459 const TokenType('PLUS_PLUS', TokenClass.UNARY_PREFIX_OPERATOR, "++"); |
| 2385 | 2460 |
| 2386 static const TokenType QUESTION = | 2461 static const TokenType QUESTION = |
| 2387 const TokenType('QUESTION', TokenClass.CONDITIONAL_OPERATOR, "?"); | 2462 const TokenType('QUESTION', TokenClass.CONDITIONAL_OPERATOR, "?"); |
| 2388 | 2463 |
| 2464 static const TokenType QUESTION_PERIOD = const TokenType( |
| 2465 'QUESTION_PERIOD', TokenClass.UNARY_POSTFIX_OPERATOR, '?.'); |
| 2466 |
| 2467 static const TokenType QUESTION_QUESTION = |
| 2468 const TokenType('QUESTION_QUESTION', TokenClass.IF_NULL_OPERATOR, '??'); |
| 2469 |
| 2470 static const TokenType QUESTION_QUESTION_EQ = const TokenType( |
| 2471 'QUESTION_QUESTION_EQ', TokenClass.ASSIGNMENT_OPERATOR, '??='); |
| 2472 |
| 2389 static const TokenType SEMICOLON = | 2473 static const TokenType SEMICOLON = |
| 2390 const TokenType('SEMICOLON', TokenClass.NO_CLASS, ";"); | 2474 const TokenType('SEMICOLON', TokenClass.NO_CLASS, ";"); |
| 2391 | 2475 |
| 2392 static const TokenType SLASH = | 2476 static const TokenType SLASH = |
| 2393 const TokenType('SLASH', TokenClass.MULTIPLICATIVE_OPERATOR, "/"); | 2477 const TokenType('SLASH', TokenClass.MULTIPLICATIVE_OPERATOR, "/"); |
| 2394 | 2478 |
| 2395 static const TokenType SLASH_EQ = | 2479 static const TokenType SLASH_EQ = |
| 2396 const TokenType('SLASH_EQ', TokenClass.ASSIGNMENT_OPERATOR, "/="); | 2480 const TokenType('SLASH_EQ', TokenClass.ASSIGNMENT_OPERATOR, "/="); |
| 2397 | 2481 |
| 2398 static const TokenType STAR = | 2482 static const TokenType STAR = |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2586 CommentToken get precedingComments => _precedingComment; | 2670 CommentToken get precedingComments => _precedingComment; |
| 2587 | 2671 |
| 2588 void set precedingComments(CommentToken comment) { | 2672 void set precedingComments(CommentToken comment) { |
| 2589 _precedingComment = comment; | 2673 _precedingComment = comment; |
| 2590 _setCommentParent(_precedingComment); | 2674 _setCommentParent(_precedingComment); |
| 2591 } | 2675 } |
| 2592 | 2676 |
| 2593 @override | 2677 @override |
| 2594 Token copy() => new TokenWithComment(type, offset, precedingComments); | 2678 Token copy() => new TokenWithComment(type, offset, precedingComments); |
| 2595 } | 2679 } |
| OLD | NEW |