Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1225)

Side by Side Diff: pkg/analyzer/lib/src/generated/scanner.dart

Issue 137863002: Issue 8742. Preserve leading line comments during java2dart translation. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Test for block-style comment translation. Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 // This code was auto-generated, is not intended to be edited, and is subject to 5 // This code was auto-generated, is not intended to be edited, and is subject to
6 // significant change. Please see the README file for more information. 6 // significant change. Please see the README file for more information.
7 7
8 library engine.scanner; 8 library engine.scanner;
9 9
10 import 'dart:collection'; 10 import 'dart:collection';
(...skipping 632 matching lines...) Expand 10 before | Expand all | Expand 10 after
643 * specification of the modification that was made, return a stream of tokens scanned from the 643 * specification of the modification that was made, return a stream of tokens scanned from the
644 * modified source. The original stream of tokens will not be modified. 644 * modified source. The original stream of tokens will not be modified.
645 * 645 *
646 * @param originalStream the stream of tokens scanned from the original source 646 * @param originalStream the stream of tokens scanned from the original source
647 * @param index the index of the first character in both the original and modi fied source that was 647 * @param index the index of the first character in both the original and modi fied source that was
648 * affected by the modification 648 * affected by the modification
649 * @param removedLength the number of characters removed from the original sou rce 649 * @param removedLength the number of characters removed from the original sou rce
650 * @param insertedLength the number of characters added to the modified source 650 * @param insertedLength the number of characters added to the modified source
651 */ 651 */
652 Token rescan(Token originalStream, int index, int removedLength, int insertedL ength) { 652 Token rescan(Token originalStream, int index, int removedLength, int insertedL ength) {
653 //
654 // Copy all of the tokens in the originalStream whose end is less than the r eplacement start.
655 // (If the replacement start is equal to the end of an existing token, then it means that the
656 // existing token might have been modified, so we need to rescan it.)
657 //
653 while (originalStream.type != TokenType.EOF && originalStream.end < index) { 658 while (originalStream.type != TokenType.EOF && originalStream.end < index) {
654 originalStream = copyAndAdvance(originalStream, 0); 659 originalStream = copyAndAdvance(originalStream, 0);
655 } 660 }
656 Token oldFirst = originalStream; 661 Token oldFirst = originalStream;
657 Token oldLeftToken = originalStream.previous; 662 Token oldLeftToken = originalStream.previous;
658 _leftToken = tail; 663 _leftToken = tail;
664 //
665 // Skip tokens in the original stream until we find a token whose offset is greater than the end
666 // of the removed region. (If the end of the removed region is equal to the beginning of an
667 // existing token, then it means that the existing token might have been mod ified, so we need to
668 // rescan it.)
669 //
659 int removedEnd = index + (removedLength == 0 ? 0 : removedLength - 1); 670 int removedEnd = index + (removedLength == 0 ? 0 : removedLength - 1);
660 while (originalStream.type != TokenType.EOF && originalStream.offset <= remo vedEnd) { 671 while (originalStream.type != TokenType.EOF && originalStream.offset <= remo vedEnd) {
661 originalStream = originalStream.next; 672 originalStream = originalStream.next;
662 } 673 }
663 Token oldLast; 674 Token oldLast;
664 Token oldRightToken; 675 Token oldRightToken;
665 if (originalStream.type != TokenType.EOF && removedEnd + 1 == originalStream .offset) { 676 if (originalStream.type != TokenType.EOF && removedEnd + 1 == originalStream .offset) {
666 oldLast = originalStream; 677 oldLast = originalStream;
667 originalStream = originalStream.next; 678 originalStream = originalStream.next;
668 oldRightToken = originalStream; 679 oldRightToken = originalStream;
669 } else { 680 } else {
670 oldLast = originalStream.previous; 681 oldLast = originalStream.previous;
671 oldRightToken = originalStream; 682 oldRightToken = originalStream;
672 } 683 }
684 //
685 // Compute the delta between the character index of characters after the mod ified region in the
686 // original source and the index of the corresponding character in the modif ied source.
687 //
673 int delta = insertedLength - removedLength; 688 int delta = insertedLength - removedLength;
689 //
690 // Compute the range of characters that are known to need to be rescanned. I f the index is
691 // within an existing token, then we need to start at the beginning of the t oken.
692 //
674 int scanStart = Math.min(oldFirst.offset, index); 693 int scanStart = Math.min(oldFirst.offset, index);
675 int oldEnd = oldLast.end + delta - 1; 694 int oldEnd = oldLast.end + delta - 1;
676 int newEnd = index + insertedLength - 1; 695 int newEnd = index + insertedLength - 1;
677 int scanEnd = Math.max(newEnd, oldEnd); 696 int scanEnd = Math.max(newEnd, oldEnd);
697 //
698 // Starting at the start of the scan region, scan tokens from the modifiedSo urce until the end
699 // of the just scanned token is greater than or equal to end of the scan reg ion in the modified
700 // source. Include trailing characters of any token that was split as a resu lt of inserted text,
701 // as in "ab" --> "a.b".
702 //
678 _reader.offset = scanStart - 1; 703 _reader.offset = scanStart - 1;
679 int next = _reader.advance(); 704 int next = _reader.advance();
680 while (next != -1 && _reader.offset <= scanEnd) { 705 while (next != -1 && _reader.offset <= scanEnd) {
681 next = bigSwitch(next); 706 next = bigSwitch(next);
682 } 707 }
708 //
709 // Copy the remaining tokens in the original stream, but apply the delta to the token's offset.
710 //
683 if (identical(originalStream.type, TokenType.EOF)) { 711 if (identical(originalStream.type, TokenType.EOF)) {
684 copyAndAdvance(originalStream, delta); 712 copyAndAdvance(originalStream, delta);
685 _rightToken = tail; 713 _rightToken = tail;
686 _rightToken.setNextWithoutSettingPrevious(_rightToken); 714 _rightToken.setNextWithoutSettingPrevious(_rightToken);
687 } else { 715 } else {
688 originalStream = copyAndAdvance(originalStream, delta); 716 originalStream = copyAndAdvance(originalStream, delta);
689 _rightToken = tail; 717 _rightToken = tail;
690 while (originalStream.type != TokenType.EOF) { 718 while (originalStream.type != TokenType.EOF) {
691 originalStream = copyAndAdvance(originalStream, delta); 719 originalStream = copyAndAdvance(originalStream, delta);
692 } 720 }
693 Token eof = copyAndAdvance(originalStream, delta); 721 Token eof = copyAndAdvance(originalStream, delta);
694 eof.setNextWithoutSettingPrevious(eof); 722 eof.setNextWithoutSettingPrevious(eof);
695 } 723 }
724 //
725 // If the index is immediately after an existing token and the inserted char acters did not
726 // change that original token, then adjust the leftToken to be the next toke n. For example, in
727 // "a; c;" --> "a;b c;", the leftToken was ";", but this code advances it to "b" since "b" is
728 // the first new token.
729 //
696 Token newFirst = _leftToken.next; 730 Token newFirst = _leftToken.next;
697 while (newFirst != _rightToken && oldFirst != oldRightToken && newFirst.type != TokenType.EOF && equals3(oldFirst, newFirst)) { 731 while (newFirst != _rightToken && oldFirst != oldRightToken && newFirst.type != TokenType.EOF && equals3(oldFirst, newFirst)) {
698 _tokenMap.put(oldFirst, newFirst); 732 _tokenMap.put(oldFirst, newFirst);
699 oldLeftToken = oldFirst; 733 oldLeftToken = oldFirst;
700 oldFirst = oldFirst.next; 734 oldFirst = oldFirst.next;
701 _leftToken = newFirst; 735 _leftToken = newFirst;
702 newFirst = newFirst.next; 736 newFirst = newFirst.next;
703 } 737 }
704 Token newLast = _rightToken.previous; 738 Token newLast = _rightToken.previous;
705 while (newLast != _leftToken && oldLast != oldLeftToken && newLast.type != T okenType.EOF && equals3(oldLast, newLast)) { 739 while (newLast != _leftToken && oldLast != oldLeftToken && newLast.type != T okenType.EOF && equals3(oldLast, newLast)) {
706 _tokenMap.put(oldLast, newLast); 740 _tokenMap.put(oldLast, newLast);
707 oldRightToken = oldLast; 741 oldRightToken = oldLast;
708 oldLast = oldLast.previous; 742 oldLast = oldLast.previous;
709 _rightToken = newLast; 743 _rightToken = newLast;
710 newLast = newLast.previous; 744 newLast = newLast.previous;
711 } 745 }
712 _hasNonWhitespaceChange2 = _leftToken.next != _rightToken || oldLeftToken.ne xt != oldRightToken; 746 _hasNonWhitespaceChange2 = _leftToken.next != _rightToken || oldLeftToken.ne xt != oldRightToken;
747 //
748 // TODO(brianwilkerson) Begin tokens are not getting associated with the cor responding end
749 // tokens (because the end tokens have not been copied when we're copyin g the begin tokens).
750 // This could have implications for parsing.
751 // TODO(brianwilkerson) Update the lineInfo.
752 //
713 return firstToken; 753 return firstToken;
714 } 754 }
715 755
716 Token copyAndAdvance(Token originalToken, int delta) { 756 Token copyAndAdvance(Token originalToken, int delta) {
717 Token copiedToken = originalToken.copy(); 757 Token copiedToken = originalToken.copy();
718 _tokenMap.put(originalToken, copiedToken); 758 _tokenMap.put(originalToken, copiedToken);
719 copiedToken.applyDelta(delta); 759 copiedToken.applyDelta(delta);
720 appendToken(copiedToken); 760 appendToken(copiedToken);
721 Token originalComment = originalToken.precedingComments; 761 Token originalComment = originalToken.precedingComments;
722 Token copiedComment = originalToken.precedingComments; 762 Token copiedComment = originalToken.precedingComments;
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after
1082 token = new BeginTokenWithComment(type, _tokenStart, _firstComment); 1122 token = new BeginTokenWithComment(type, _tokenStart, _firstComment);
1083 _firstComment = null; 1123 _firstComment = null;
1084 _lastComment = null; 1124 _lastComment = null;
1085 } 1125 }
1086 _tail = _tail.setNext(token); 1126 _tail = _tail.setNext(token);
1087 _groupingStack.add(token); 1127 _groupingStack.add(token);
1088 _stackEnd++; 1128 _stackEnd++;
1089 } 1129 }
1090 1130
1091 void appendCommentToken(TokenType type, String value) { 1131 void appendCommentToken(TokenType type, String value) {
1132 // Ignore comment tokens if client specified that it doesn't need them.
1092 if (!_preserveComments) { 1133 if (!_preserveComments) {
1093 return; 1134 return;
1094 } 1135 }
1136 // OK, remember comment tokens.
1095 if (_firstComment == null) { 1137 if (_firstComment == null) {
1096 _firstComment = new StringToken(type, value, _tokenStart); 1138 _firstComment = new StringToken(type, value, _tokenStart);
1097 _lastComment = _firstComment; 1139 _lastComment = _firstComment;
1098 } else { 1140 } else {
1099 _lastComment = _lastComment.setNext(new StringToken(type, value, _tokenSta rt)); 1141 _lastComment = _lastComment.setNext(new StringToken(type, value, _tokenSta rt));
1100 } 1142 }
1101 } 1143 }
1102 1144
1103 void appendEndToken(TokenType type, TokenType beginType) { 1145 void appendEndToken(TokenType type, TokenType beginType) {
1104 Token token; 1146 Token token;
(...skipping 16 matching lines...) Expand all
1121 1163
1122 void appendEofToken() { 1164 void appendEofToken() {
1123 Token eofToken; 1165 Token eofToken;
1124 if (_firstComment == null) { 1166 if (_firstComment == null) {
1125 eofToken = new Token(TokenType.EOF, _reader.offset + 1); 1167 eofToken = new Token(TokenType.EOF, _reader.offset + 1);
1126 } else { 1168 } else {
1127 eofToken = new TokenWithComment(TokenType.EOF, _reader.offset + 1, _firstC omment); 1169 eofToken = new TokenWithComment(TokenType.EOF, _reader.offset + 1, _firstC omment);
1128 _firstComment = null; 1170 _firstComment = null;
1129 _lastComment = null; 1171 _lastComment = null;
1130 } 1172 }
1173 // The EOF token points to itself so that there is always infinite look-ahea d.
1131 eofToken.setNext(eofToken); 1174 eofToken.setNext(eofToken);
1132 _tail = _tail.setNext(eofToken); 1175 _tail = _tail.setNext(eofToken);
1133 if (_stackEnd >= 0) { 1176 if (_stackEnd >= 0) {
1134 _hasUnmatchedGroups2 = true; 1177 _hasUnmatchedGroups2 = true;
1135 } 1178 }
1136 } 1179 }
1137 1180
1138 void appendKeywordToken(Keyword keyword) { 1181 void appendKeywordToken(Keyword keyword) {
1139 if (_firstComment == null) { 1182 if (_firstComment == null) {
1140 _tail = _tail.setNext(new KeywordToken(keyword, _tokenStart)); 1183 _tail = _tail.setNext(new KeywordToken(keyword, _tokenStart));
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
1198 */ 1241 */
1199 BeginToken findTokenMatchingClosingBraceInInterpolationExpression() { 1242 BeginToken findTokenMatchingClosingBraceInInterpolationExpression() {
1200 while (_stackEnd >= 0) { 1243 while (_stackEnd >= 0) {
1201 BeginToken begin = _groupingStack[_stackEnd]; 1244 BeginToken begin = _groupingStack[_stackEnd];
1202 if (identical(begin.type, TokenType.OPEN_CURLY_BRACKET) || identical(begin .type, TokenType.STRING_INTERPOLATION_EXPRESSION)) { 1245 if (identical(begin.type, TokenType.OPEN_CURLY_BRACKET) || identical(begin .type, TokenType.STRING_INTERPOLATION_EXPRESSION)) {
1203 return begin; 1246 return begin;
1204 } 1247 }
1205 _hasUnmatchedGroups2 = true; 1248 _hasUnmatchedGroups2 = true;
1206 _groupingStack.removeAt(_stackEnd--); 1249 _groupingStack.removeAt(_stackEnd--);
1207 } 1250 }
1251 //
1252 // We should never get to this point because we wouldn't be inside a string interpolation
1253 // expression unless we had previously found the start of the expression.
1254 //
1208 return null; 1255 return null;
1209 } 1256 }
1210 1257
1211 /** 1258 /**
1212 * Report an error at the current offset. 1259 * Report an error at the current offset.
1213 * 1260 *
1214 * @param errorCode the error code indicating the nature of the error 1261 * @param errorCode the error code indicating the nature of the error
1215 * @param arguments any arguments needed to complete the error message 1262 * @param arguments any arguments needed to complete the error message
1216 */ 1263 */
1217 void reportError(ScannerErrorCode errorCode, List<Object> arguments) { 1264 void reportError(ScannerErrorCode errorCode, List<Object> arguments) {
(...skipping 16 matching lines...) Expand all
1234 if (next == choice) { 1281 if (next == choice) {
1235 appendToken3(yesType, offset); 1282 appendToken3(yesType, offset);
1236 return _reader.advance(); 1283 return _reader.advance();
1237 } else { 1284 } else {
1238 appendToken3(noType, offset); 1285 appendToken3(noType, offset);
1239 return next; 1286 return next;
1240 } 1287 }
1241 } 1288 }
1242 1289
1243 int tokenizeAmpersand(int next) { 1290 int tokenizeAmpersand(int next) {
1291 // && &= &
1244 next = _reader.advance(); 1292 next = _reader.advance();
1245 if (next == 0x26) { 1293 if (next == 0x26) {
1246 appendToken2(TokenType.AMPERSAND_AMPERSAND); 1294 appendToken2(TokenType.AMPERSAND_AMPERSAND);
1247 return _reader.advance(); 1295 return _reader.advance();
1248 } else if (next == 0x3D) { 1296 } else if (next == 0x3D) {
1249 appendToken2(TokenType.AMPERSAND_EQ); 1297 appendToken2(TokenType.AMPERSAND_EQ);
1250 return _reader.advance(); 1298 return _reader.advance();
1251 } else { 1299 } else {
1252 appendToken2(TokenType.AMPERSAND); 1300 appendToken2(TokenType.AMPERSAND);
1253 return next; 1301 return next;
1254 } 1302 }
1255 } 1303 }
1256 1304
1257 int tokenizeBar(int next) { 1305 int tokenizeBar(int next) {
1306 // | || |=
1258 next = _reader.advance(); 1307 next = _reader.advance();
1259 if (next == 0x7C) { 1308 if (next == 0x7C) {
1260 appendToken2(TokenType.BAR_BAR); 1309 appendToken2(TokenType.BAR_BAR);
1261 return _reader.advance(); 1310 return _reader.advance();
1262 } else if (next == 0x3D) { 1311 } else if (next == 0x3D) {
1263 appendToken2(TokenType.BAR_EQ); 1312 appendToken2(TokenType.BAR_EQ);
1264 return _reader.advance(); 1313 return _reader.advance();
1265 } else { 1314 } else {
1266 appendToken2(TokenType.BAR); 1315 appendToken2(TokenType.BAR);
1267 return next; 1316 return next;
1268 } 1317 }
1269 } 1318 }
1270 1319
1271 int tokenizeCaret(int next) => select(0x3D, TokenType.CARET_EQ, TokenType.CARE T); 1320 int tokenizeCaret(int next) => select(0x3D, TokenType.CARET_EQ, TokenType.CARE T);
1272 1321
1273 int tokenizeDotOrNumber(int next) { 1322 int tokenizeDotOrNumber(int next) {
1274 int start = _reader.offset; 1323 int start = _reader.offset;
1275 next = _reader.advance(); 1324 next = _reader.advance();
1276 if (0x30 <= next && next <= 0x39) { 1325 if (0x30 <= next && next <= 0x39) {
1277 return tokenizeFractionPart(next, start); 1326 return tokenizeFractionPart(next, start);
1278 } else if (0x2E == next) { 1327 } else if (0x2E == next) {
1279 return select(0x2E, TokenType.PERIOD_PERIOD_PERIOD, TokenType.PERIOD_PERIO D); 1328 return select(0x2E, TokenType.PERIOD_PERIOD_PERIOD, TokenType.PERIOD_PERIO D);
1280 } else { 1329 } else {
1281 appendToken2(TokenType.PERIOD); 1330 appendToken2(TokenType.PERIOD);
1282 return next; 1331 return next;
1283 } 1332 }
1284 } 1333 }
1285 1334
1286 int tokenizeEquals(int next) { 1335 int tokenizeEquals(int next) {
1336 // = == =>
1287 next = _reader.advance(); 1337 next = _reader.advance();
1288 if (next == 0x3D) { 1338 if (next == 0x3D) {
1289 appendToken2(TokenType.EQ_EQ); 1339 appendToken2(TokenType.EQ_EQ);
1290 return _reader.advance(); 1340 return _reader.advance();
1291 } else if (next == 0x3E) { 1341 } else if (next == 0x3E) {
1292 appendToken2(TokenType.FUNCTION); 1342 appendToken2(TokenType.FUNCTION);
1293 return _reader.advance(); 1343 return _reader.advance();
1294 } 1344 }
1295 appendToken2(TokenType.EQ); 1345 appendToken2(TokenType.EQ);
1296 return next; 1346 return next;
1297 } 1347 }
1298 1348
1299 int tokenizeExclamation(int next) { 1349 int tokenizeExclamation(int next) {
1350 // ! !=
1300 next = _reader.advance(); 1351 next = _reader.advance();
1301 if (next == 0x3D) { 1352 if (next == 0x3D) {
1302 appendToken2(TokenType.BANG_EQ); 1353 appendToken2(TokenType.BANG_EQ);
1303 return _reader.advance(); 1354 return _reader.advance();
1304 } 1355 }
1305 appendToken2(TokenType.BANG); 1356 appendToken2(TokenType.BANG);
1306 return next; 1357 return next;
1307 } 1358 }
1308 1359
1309 int tokenizeExponent(int next) { 1360 int tokenizeExponent(int next) {
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
1347 return select2(0x2E, TokenType.PERIOD_PERIOD_PERIOD, TokenType.PERIOD_PE RIOD, _reader.offset - 1); 1398 return select2(0x2E, TokenType.PERIOD_PERIOD_PERIOD, TokenType.PERIOD_PE RIOD, _reader.offset - 1);
1348 } 1399 }
1349 appendToken3(TokenType.PERIOD, _reader.offset - 1); 1400 appendToken3(TokenType.PERIOD, _reader.offset - 1);
1350 return bigSwitch(next); 1401 return bigSwitch(next);
1351 } 1402 }
1352 appendStringToken(TokenType.DOUBLE, _reader.getString(start, next < 0 ? 0 : -1)); 1403 appendStringToken(TokenType.DOUBLE, _reader.getString(start, next < 0 ? 0 : -1));
1353 return next; 1404 return next;
1354 } 1405 }
1355 1406
1356 int tokenizeGreaterThan(int next) { 1407 int tokenizeGreaterThan(int next) {
1408 // > >= >> >>=
1357 next = _reader.advance(); 1409 next = _reader.advance();
1358 if (0x3D == next) { 1410 if (0x3D == next) {
1359 appendToken2(TokenType.GT_EQ); 1411 appendToken2(TokenType.GT_EQ);
1360 return _reader.advance(); 1412 return _reader.advance();
1361 } else if (0x3E == next) { 1413 } else if (0x3E == next) {
1362 next = _reader.advance(); 1414 next = _reader.advance();
1363 if (0x3D == next) { 1415 if (0x3D == next) {
1364 appendToken2(TokenType.GT_GT_EQ); 1416 appendToken2(TokenType.GT_GT_EQ);
1365 return _reader.advance(); 1417 return _reader.advance();
1366 } else { 1418 } else {
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
1467 return tokenizeIdentifier(next, start, allowDollar); 1519 return tokenizeIdentifier(next, start, allowDollar);
1468 } else if (next < 128) { 1520 } else if (next < 128) {
1469 appendKeywordToken(state.keyword()); 1521 appendKeywordToken(state.keyword());
1470 return next; 1522 return next;
1471 } else { 1523 } else {
1472 return tokenizeIdentifier(next, start, allowDollar); 1524 return tokenizeIdentifier(next, start, allowDollar);
1473 } 1525 }
1474 } 1526 }
1475 1527
1476 int tokenizeLessThan(int next) { 1528 int tokenizeLessThan(int next) {
1529 // < <= << <<=
1477 next = _reader.advance(); 1530 next = _reader.advance();
1478 if (0x3D == next) { 1531 if (0x3D == next) {
1479 appendToken2(TokenType.LT_EQ); 1532 appendToken2(TokenType.LT_EQ);
1480 return _reader.advance(); 1533 return _reader.advance();
1481 } else if (0x3C == next) { 1534 } else if (0x3C == next) {
1482 return select(0x3D, TokenType.LT_LT_EQ, TokenType.LT_LT); 1535 return select(0x3D, TokenType.LT_LT_EQ, TokenType.LT_LT);
1483 } else { 1536 } else {
1484 appendToken2(TokenType.LT); 1537 appendToken2(TokenType.LT);
1485 return next; 1538 return next;
1486 } 1539 }
1487 } 1540 }
1488 1541
1489 int tokenizeMinus(int next) { 1542 int tokenizeMinus(int next) {
1543 // - -- -=
1490 next = _reader.advance(); 1544 next = _reader.advance();
1491 if (next == 0x2D) { 1545 if (next == 0x2D) {
1492 appendToken2(TokenType.MINUS_MINUS); 1546 appendToken2(TokenType.MINUS_MINUS);
1493 return _reader.advance(); 1547 return _reader.advance();
1494 } else if (next == 0x3D) { 1548 } else if (next == 0x3D) {
1495 appendToken2(TokenType.MINUS_EQ); 1549 appendToken2(TokenType.MINUS_EQ);
1496 return _reader.advance(); 1550 return _reader.advance();
1497 } else { 1551 } else {
1498 appendToken2(TokenType.MINUS); 1552 appendToken2(TokenType.MINUS);
1499 return next; 1553 return next;
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
1644 } else if (next == 0x65 || next == 0x45) { 1698 } else if (next == 0x65 || next == 0x45) {
1645 return tokenizeFractionPart(next, start); 1699 return tokenizeFractionPart(next, start);
1646 } else { 1700 } else {
1647 appendStringToken(TokenType.INT, _reader.getString(start, next < 0 ? 0 : -1)); 1701 appendStringToken(TokenType.INT, _reader.getString(start, next < 0 ? 0 : -1));
1648 return next; 1702 return next;
1649 } 1703 }
1650 } 1704 }
1651 } 1705 }
1652 1706
1653 int tokenizeOpenSquareBracket(int next) { 1707 int tokenizeOpenSquareBracket(int next) {
1708 // [ [] []=
1654 next = _reader.advance(); 1709 next = _reader.advance();
1655 if (next == 0x5D) { 1710 if (next == 0x5D) {
1656 return select(0x3D, TokenType.INDEX_EQ, TokenType.INDEX); 1711 return select(0x3D, TokenType.INDEX_EQ, TokenType.INDEX);
1657 } else { 1712 } else {
1658 appendBeginToken(TokenType.OPEN_SQUARE_BRACKET); 1713 appendBeginToken(TokenType.OPEN_SQUARE_BRACKET);
1659 return next; 1714 return next;
1660 } 1715 }
1661 } 1716 }
1662 1717
1663 int tokenizePercent(int next) => select(0x3D, TokenType.PERCENT_EQ, TokenType. PERCENT); 1718 int tokenizePercent(int next) => select(0x3D, TokenType.PERCENT_EQ, TokenType. PERCENT);
1664 1719
1665 int tokenizePlus(int next) { 1720 int tokenizePlus(int next) {
1721 // + ++ +=
1666 next = _reader.advance(); 1722 next = _reader.advance();
1667 if (0x2B == next) { 1723 if (0x2B == next) {
1668 appendToken2(TokenType.PLUS_PLUS); 1724 appendToken2(TokenType.PLUS_PLUS);
1669 return _reader.advance(); 1725 return _reader.advance();
1670 } else if (0x3D == next) { 1726 } else if (0x3D == next) {
1671 appendToken2(TokenType.PLUS_EQ); 1727 appendToken2(TokenType.PLUS_EQ);
1672 return _reader.advance(); 1728 return _reader.advance();
1673 } else { 1729 } else {
1674 appendToken2(TokenType.PLUS); 1730 appendToken2(TokenType.PLUS);
1675 return next; 1731 return next;
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
1743 return next; 1799 return next;
1744 } 1800 }
1745 } 1801 }
1746 1802
1747 int tokenizeString(int next, int start, bool raw) { 1803 int tokenizeString(int next, int start, bool raw) {
1748 int quoteChar = next; 1804 int quoteChar = next;
1749 next = _reader.advance(); 1805 next = _reader.advance();
1750 if (quoteChar == next) { 1806 if (quoteChar == next) {
1751 next = _reader.advance(); 1807 next = _reader.advance();
1752 if (quoteChar == next) { 1808 if (quoteChar == next) {
1809 // Multiline string.
1753 return tokenizeMultiLineString(quoteChar, start, raw); 1810 return tokenizeMultiLineString(quoteChar, start, raw);
1754 } else { 1811 } else {
1812 // Empty string.
1755 appendStringToken(TokenType.STRING, _reader.getString(start, -1)); 1813 appendStringToken(TokenType.STRING, _reader.getString(start, -1));
1756 return next; 1814 return next;
1757 } 1815 }
1758 } 1816 }
1759 if (raw) { 1817 if (raw) {
1760 return tokenizeSingleLineRawString(next, quoteChar, start); 1818 return tokenizeSingleLineRawString(next, quoteChar, start);
1761 } else { 1819 } else {
1762 return tokenizeSingleLineString(next, quoteChar, start); 1820 return tokenizeSingleLineString(next, quoteChar, start);
1763 } 1821 }
1764 } 1822 }
1765 1823
1766 int tokenizeStringInterpolation(int start) { 1824 int tokenizeStringInterpolation(int start) {
1767 beginToken(); 1825 beginToken();
1768 int next = _reader.advance(); 1826 int next = _reader.advance();
1769 if (next == 0x7B) { 1827 if (next == 0x7B) {
1770 return tokenizeInterpolatedExpression(next, start); 1828 return tokenizeInterpolatedExpression(next, start);
1771 } else { 1829 } else {
1772 return tokenizeInterpolatedIdentifier(next, start); 1830 return tokenizeInterpolatedIdentifier(next, start);
1773 } 1831 }
1774 } 1832 }
1775 1833
1776 int tokenizeTag(int next) { 1834 int tokenizeTag(int next) {
1835 // # or #!.*[\n\r]
1777 if (_reader.offset == 0) { 1836 if (_reader.offset == 0) {
1778 if (_reader.peek() == 0x21) { 1837 if (_reader.peek() == 0x21) {
1779 do { 1838 do {
1780 next = _reader.advance(); 1839 next = _reader.advance();
1781 } while (next != 0xA && next != 0xD && next > 0); 1840 } while (next != 0xA && next != 0xD && next > 0);
1782 appendStringToken(TokenType.SCRIPT_TAG, _reader.getString(_tokenStart, 0 )); 1841 appendStringToken(TokenType.SCRIPT_TAG, _reader.getString(_tokenStart, 0 ));
1783 return next; 1842 return next;
1784 } 1843 }
1785 } 1844 }
1786 appendToken2(TokenType.HASH); 1845 appendToken2(TokenType.HASH);
1787 return _reader.advance(); 1846 return _reader.advance();
1788 } 1847 }
1789 1848
1790 int tokenizeTilde(int next) { 1849 int tokenizeTilde(int next) {
1850 // ~ ~/ ~/=
1791 next = _reader.advance(); 1851 next = _reader.advance();
1792 if (next == 0x2F) { 1852 if (next == 0x2F) {
1793 return select(0x3D, TokenType.TILDE_SLASH_EQ, TokenType.TILDE_SLASH); 1853 return select(0x3D, TokenType.TILDE_SLASH_EQ, TokenType.TILDE_SLASH);
1794 } else { 1854 } else {
1795 appendToken2(TokenType.TILDE); 1855 appendToken2(TokenType.TILDE);
1796 return next; 1856 return next;
1797 } 1857 }
1798 } 1858 }
1799 } 1859 }
1800 1860
(...skipping 866 matching lines...) Expand 10 before | Expand all | Expand 10 after
2667 * @return `true` if this token type represents an operator that can be define d by users 2727 * @return `true` if this token type represents an operator that can be define d by users
2668 */ 2728 */
2669 bool get isUserDefinableOperator => identical(_lexeme, "==") || identical(_lex eme, "~") || identical(_lexeme, "[]") || identical(_lexeme, "[]=") || identical( _lexeme, "*") || identical(_lexeme, "/") || identical(_lexeme, "%") || identical (_lexeme, "~/") || identical(_lexeme, "+") || identical(_lexeme, "-") || identic al(_lexeme, "<<") || identical(_lexeme, ">>") || identical(_lexeme, ">=") || ide ntical(_lexeme, ">") || identical(_lexeme, "<=") || identical(_lexeme, "<") || i dentical(_lexeme, "&") || identical(_lexeme, "^") || identical(_lexeme, "|"); 2729 bool get isUserDefinableOperator => identical(_lexeme, "==") || identical(_lex eme, "~") || identical(_lexeme, "[]") || identical(_lexeme, "[]=") || identical( _lexeme, "*") || identical(_lexeme, "/") || identical(_lexeme, "%") || identical (_lexeme, "~/") || identical(_lexeme, "+") || identical(_lexeme, "-") || identic al(_lexeme, "<<") || identical(_lexeme, ">>") || identical(_lexeme, ">=") || ide ntical(_lexeme, ">") || identical(_lexeme, "<=") || identical(_lexeme, "<") || i dentical(_lexeme, "&") || identical(_lexeme, "^") || identical(_lexeme, "|");
2670 } 2730 }
2671 2731
2672 class TokenType_EOF extends TokenType { 2732 class TokenType_EOF extends TokenType {
2673 TokenType_EOF(String name, int ordinal, TokenClass arg0, String arg1) : super. con2(name, ordinal, arg0, arg1); 2733 TokenType_EOF(String name, int ordinal, TokenClass arg0, String arg1) : super. con2(name, ordinal, arg0, arg1);
2674 2734
2675 String toString() => "-eof-"; 2735 String toString() => "-eof-";
2676 } 2736 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/generated/resolver.dart ('k') | pkg/analyzer/lib/src/generated/sdk_io.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698