| 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 library fasta.scanner.abstract_scanner; | 5 library fasta.scanner.abstract_scanner; |
| 6 | 6 |
| 7 import '../scanner.dart' show | 7 import '../scanner.dart' show |
| 8 ErrorToken, | 8 ErrorToken, |
| 9 Scanner, | 9 Scanner, |
| 10 buildUnexpectedCharacterToken; | 10 buildUnexpectedCharacterToken; |
| (...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 234 if ($a <= next && next <= $z) { | 234 if ($a <= next && next <= $z) { |
| 235 if (identical($r, next)) { | 235 if (identical($r, next)) { |
| 236 return tokenizeRawStringKeywordOrIdentifier(next); | 236 return tokenizeRawStringKeywordOrIdentifier(next); |
| 237 } | 237 } |
| 238 return tokenizeKeywordOrIdentifier(next, true); | 238 return tokenizeKeywordOrIdentifier(next, true); |
| 239 } | 239 } |
| 240 | 240 |
| 241 if (($A <= next && next <= $Z) || | 241 if (($A <= next && next <= $Z) || |
| 242 identical(next, $_) || | 242 identical(next, $_) || |
| 243 identical(next, $$)) { | 243 identical(next, $$)) { |
| 244 return tokenizeIdentifier(next, scanOffset, true); | 244 return tokenizeKeywordOrIdentifier(next, true); |
| 245 } | 245 } |
| 246 | 246 |
| 247 if (identical(next, $LT)) { | 247 if (identical(next, $LT)) { |
| 248 return tokenizeLessThan(next); | 248 return tokenizeLessThan(next); |
| 249 } | 249 } |
| 250 | 250 |
| 251 if (identical(next, $GT)) { | 251 if (identical(next, $GT)) { |
| 252 return tokenizeGreaterThan(next); | 252 return tokenizeGreaterThan(next); |
| 253 } | 253 } |
| 254 | 254 |
| (...skipping 546 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 801 int start = scanOffset; | 801 int start = scanOffset; |
| 802 next = advance(); | 802 next = advance(); |
| 803 return tokenizeString(next, start, true); | 803 return tokenizeString(next, start, true); |
| 804 } | 804 } |
| 805 return tokenizeKeywordOrIdentifier(next, true); | 805 return tokenizeKeywordOrIdentifier(next, true); |
| 806 } | 806 } |
| 807 | 807 |
| 808 int tokenizeKeywordOrIdentifier(int next, bool allowDollar) { | 808 int tokenizeKeywordOrIdentifier(int next, bool allowDollar) { |
| 809 KeywordState state = KeywordState.KEYWORD_STATE; | 809 KeywordState state = KeywordState.KEYWORD_STATE; |
| 810 int start = scanOffset; | 810 int start = scanOffset; |
| 811 // We allow a leading capital character. |
| 812 if ($A <= next && next <= $Z) { |
| 813 state = state.nextCapital(next); |
| 814 next = advance(); |
| 815 } else if ($a <= next && next <= $z){ |
| 816 // Do the first next call outside the loop to avoid an additional test |
| 817 // and to make the loop monomorphic. |
| 818 state = state.next(next); |
| 819 next = advance(); |
| 820 } |
| 811 while (state != null && $a <= next && next <= $z) { | 821 while (state != null && $a <= next && next <= $z) { |
| 812 state = state.next(next); | 822 state = state.next(next); |
| 813 next = advance(); | 823 next = advance(); |
| 814 } | 824 } |
| 815 if (state == null || state.keyword == null) { | 825 if (state == null || state.keyword == null) { |
| 816 return tokenizeIdentifier(next, start, allowDollar); | 826 return tokenizeIdentifier(next, start, allowDollar); |
| 817 } | 827 } |
| 818 if (($A <= next && next <= $Z) || | 828 if (($A <= next && next <= $Z) || |
| 819 ($0 <= next && next <= $9) || | 829 ($0 <= next && next <= $9) || |
| 820 identical(next, $_) || | 830 identical(next, $_) || |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 938 } | 948 } |
| 939 if (identical(next, $EOF)) return next; | 949 if (identical(next, $EOF)) return next; |
| 940 next = advance(); // Move past the $STX. | 950 next = advance(); // Move past the $STX. |
| 941 beginToken(); // The string interpolation suffix starts here. | 951 beginToken(); // The string interpolation suffix starts here. |
| 942 return next; | 952 return next; |
| 943 } | 953 } |
| 944 | 954 |
| 945 int tokenizeInterpolatedIdentifier(int next) { | 955 int tokenizeInterpolatedIdentifier(int next) { |
| 946 appendPrecedenceToken(STRING_INTERPOLATION_IDENTIFIER_INFO); | 956 appendPrecedenceToken(STRING_INTERPOLATION_IDENTIFIER_INFO); |
| 947 | 957 |
| 948 if ($a <= next && next <= $z) { | 958 if ($a <= next && next <= $z || |
| 959 $A <= next && next <= $Z || |
| 960 identical(next, $_)) { |
| 949 beginToken(); // The identifier starts here. | 961 beginToken(); // The identifier starts here. |
| 950 next = tokenizeKeywordOrIdentifier(next, false); | 962 next = tokenizeKeywordOrIdentifier(next, false); |
| 951 } else if (($A <= next && next <= $Z) || identical(next, $_)) { | |
| 952 beginToken(); // The identifier starts here. | |
| 953 next = tokenizeIdentifier(next, scanOffset, false); | |
| 954 } else { | 963 } else { |
| 955 unterminated(r'$', shouldAdvance: false); | 964 unterminated(r'$', shouldAdvance: false); |
| 956 } | 965 } |
| 957 beginToken(); // The string interpolation suffix starts here. | 966 beginToken(); // The string interpolation suffix starts here. |
| 958 return next; | 967 return next; |
| 959 } | 968 } |
| 960 | 969 |
| 961 int tokenizeSingleLineRawString(int next, int quoteChar, int start) { | 970 int tokenizeSingleLineRawString(int next, int quoteChar, int start) { |
| 962 bool asciiOnly = true; | 971 bool asciiOnly = true; |
| 963 while (next != $EOF) { | 972 while (next != $EOF) { |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1158 | 1167 |
| 1159 PrecedenceInfo closeBraceInfoFor(BeginGroupToken begin) { | 1168 PrecedenceInfo closeBraceInfoFor(BeginGroupToken begin) { |
| 1160 return const { | 1169 return const { |
| 1161 '(': CLOSE_PAREN_INFO, | 1170 '(': CLOSE_PAREN_INFO, |
| 1162 '[': CLOSE_SQUARE_BRACKET_INFO, | 1171 '[': CLOSE_SQUARE_BRACKET_INFO, |
| 1163 '{': CLOSE_CURLY_BRACKET_INFO, | 1172 '{': CLOSE_CURLY_BRACKET_INFO, |
| 1164 '<': GT_INFO, | 1173 '<': GT_INFO, |
| 1165 r'${': CLOSE_CURLY_BRACKET_INFO, | 1174 r'${': CLOSE_CURLY_BRACKET_INFO, |
| 1166 }[begin.value]; | 1175 }[begin.value]; |
| 1167 } | 1176 } |
| OLD | NEW |