| 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 // 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 1249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1260 // | 1260 // |
| 1261 return null; | 1261 return null; |
| 1262 } | 1262 } |
| 1263 | 1263 |
| 1264 /** | 1264 /** |
| 1265 * Report an error at the current offset. | 1265 * Report an error at the current offset. |
| 1266 * | 1266 * |
| 1267 * @param errorCode the error code indicating the nature of the error | 1267 * @param errorCode the error code indicating the nature of the error |
| 1268 * @param arguments any arguments needed to complete the error message | 1268 * @param arguments any arguments needed to complete the error message |
| 1269 */ | 1269 */ |
| 1270 void _reportError(ScannerErrorCode errorCode, List<Object> arguments) { | 1270 void _reportError(ScannerErrorCode errorCode, [List<Object> arguments]) { |
| 1271 _errorListener.onError(new AnalysisError.con2(source, _reader.offset, 1, err
orCode, arguments)); | 1271 _errorListener.onError(new AnalysisError.con2(source, _reader.offset, 1, err
orCode, arguments)); |
| 1272 } | 1272 } |
| 1273 | 1273 |
| 1274 int _select(int choice, TokenType yesType, TokenType noType) { | 1274 int _select(int choice, TokenType yesType, TokenType noType) { |
| 1275 int next = _reader.advance(); | 1275 int next = _reader.advance(); |
| 1276 if (next == choice) { | 1276 if (next == choice) { |
| 1277 _appendTokenOfType(yesType); | 1277 _appendTokenOfType(yesType); |
| 1278 return _reader.advance(); | 1278 return _reader.advance(); |
| 1279 } else { | 1279 } else { |
| 1280 _appendTokenOfType(noType); | 1280 _appendTokenOfType(noType); |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1366 int _tokenizeExponent(int next) { | 1366 int _tokenizeExponent(int next) { |
| 1367 if (next == 0x2B || next == 0x2D) { | 1367 if (next == 0x2B || next == 0x2D) { |
| 1368 next = _reader.advance(); | 1368 next = _reader.advance(); |
| 1369 } | 1369 } |
| 1370 bool hasDigits = false; | 1370 bool hasDigits = false; |
| 1371 while (true) { | 1371 while (true) { |
| 1372 if (0x30 <= next && next <= 0x39) { | 1372 if (0x30 <= next && next <= 0x39) { |
| 1373 hasDigits = true; | 1373 hasDigits = true; |
| 1374 } else { | 1374 } else { |
| 1375 if (!hasDigits) { | 1375 if (!hasDigits) { |
| 1376 _reportError(ScannerErrorCode.MISSING_DIGIT, []); | 1376 _reportError(ScannerErrorCode.MISSING_DIGIT); |
| 1377 } | 1377 } |
| 1378 return next; | 1378 return next; |
| 1379 } | 1379 } |
| 1380 next = _reader.advance(); | 1380 next = _reader.advance(); |
| 1381 } | 1381 } |
| 1382 } | 1382 } |
| 1383 | 1383 |
| 1384 int _tokenizeFractionPart(int next, int start) { | 1384 int _tokenizeFractionPart(int next, int start) { |
| 1385 bool done = false; | 1385 bool done = false; |
| 1386 bool hasDigit = false; | 1386 bool hasDigit = false; |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1433 | 1433 |
| 1434 int _tokenizeHex(int next) { | 1434 int _tokenizeHex(int next) { |
| 1435 int start = _reader.offset - 1; | 1435 int start = _reader.offset - 1; |
| 1436 bool hasDigits = false; | 1436 bool hasDigits = false; |
| 1437 while (true) { | 1437 while (true) { |
| 1438 next = _reader.advance(); | 1438 next = _reader.advance(); |
| 1439 if ((0x30 <= next && next <= 0x39) || (0x41 <= next && next <= 0x46) || (0
x61 <= next && next <= 0x66)) { | 1439 if ((0x30 <= next && next <= 0x39) || (0x41 <= next && next <= 0x46) || (0
x61 <= next && next <= 0x66)) { |
| 1440 hasDigits = true; | 1440 hasDigits = true; |
| 1441 } else { | 1441 } else { |
| 1442 if (!hasDigits) { | 1442 if (!hasDigits) { |
| 1443 _reportError(ScannerErrorCode.MISSING_HEX_DIGIT, []); | 1443 _reportError(ScannerErrorCode.MISSING_HEX_DIGIT); |
| 1444 } | 1444 } |
| 1445 _appendStringToken(TokenType.HEXADECIMAL, _reader.getString(start, next
< 0 ? 0 : -1)); | 1445 _appendStringToken(TokenType.HEXADECIMAL, _reader.getString(start, next
< 0 ? 0 : -1)); |
| 1446 return next; | 1446 return next; |
| 1447 } | 1447 } |
| 1448 } | 1448 } |
| 1449 } | 1449 } |
| 1450 | 1450 |
| 1451 int _tokenizeHexOrNumber(int next) { | 1451 int _tokenizeHexOrNumber(int next) { |
| 1452 int x = _reader.peek(); | 1452 int x = _reader.peek(); |
| 1453 if (x == 0x78 || x == 0x58) { | 1453 if (x == 0x78 || x == 0x58) { |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1553 _appendTokenOfType(TokenType.MINUS); | 1553 _appendTokenOfType(TokenType.MINUS); |
| 1554 return next; | 1554 return next; |
| 1555 } | 1555 } |
| 1556 } | 1556 } |
| 1557 | 1557 |
| 1558 int _tokenizeMultiLineComment(int next) { | 1558 int _tokenizeMultiLineComment(int next) { |
| 1559 int nesting = 1; | 1559 int nesting = 1; |
| 1560 next = _reader.advance(); | 1560 next = _reader.advance(); |
| 1561 while (true) { | 1561 while (true) { |
| 1562 if (-1 == next) { | 1562 if (-1 == next) { |
| 1563 _reportError(ScannerErrorCode.UNTERMINATED_MULTI_LINE_COMMENT, []); | 1563 _reportError(ScannerErrorCode.UNTERMINATED_MULTI_LINE_COMMENT); |
| 1564 _appendCommentToken(TokenType.MULTI_LINE_COMMENT, _reader.getString(_tok
enStart, 0)); | 1564 _appendCommentToken(TokenType.MULTI_LINE_COMMENT, _reader.getString(_tok
enStart, 0)); |
| 1565 return next; | 1565 return next; |
| 1566 } else if (0x2A == next) { | 1566 } else if (0x2A == next) { |
| 1567 next = _reader.advance(); | 1567 next = _reader.advance(); |
| 1568 if (0x2F == next) { | 1568 if (0x2F == next) { |
| 1569 --nesting; | 1569 --nesting; |
| 1570 if (0 == nesting) { | 1570 if (0 == nesting) { |
| 1571 _appendCommentToken(TokenType.MULTI_LINE_COMMENT, _reader.getString(
_tokenStart, 0)); | 1571 _appendCommentToken(TokenType.MULTI_LINE_COMMENT, _reader.getString(
_tokenStart, 0)); |
| 1572 return _reader.advance(); | 1572 return _reader.advance(); |
| 1573 } else { | 1573 } else { |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1615 } | 1615 } |
| 1616 next = _reader.advance(); | 1616 next = _reader.advance(); |
| 1617 if (next == quoteChar) { | 1617 if (next == quoteChar) { |
| 1618 next = _reader.advance(); | 1618 next = _reader.advance(); |
| 1619 if (next == quoteChar) { | 1619 if (next == quoteChar) { |
| 1620 _appendStringToken(TokenType.STRING, _reader.getString(start, 0)); | 1620 _appendStringToken(TokenType.STRING, _reader.getString(start, 0)); |
| 1621 return _reader.advance(); | 1621 return _reader.advance(); |
| 1622 } | 1622 } |
| 1623 } | 1623 } |
| 1624 } | 1624 } |
| 1625 _reportError(ScannerErrorCode.UNTERMINATED_STRING_LITERAL, []); | 1625 _reportError(ScannerErrorCode.UNTERMINATED_STRING_LITERAL); |
| 1626 _appendStringToken(TokenType.STRING, _reader.getString(start, 0)); | 1626 _appendStringToken(TokenType.STRING, _reader.getString(start, 0)); |
| 1627 return _reader.advance(); | 1627 return _reader.advance(); |
| 1628 } | 1628 } |
| 1629 | 1629 |
| 1630 int _tokenizeMultiLineString(int quoteChar, int start, bool raw) { | 1630 int _tokenizeMultiLineString(int quoteChar, int start, bool raw) { |
| 1631 if (raw) { | 1631 if (raw) { |
| 1632 return _tokenizeMultiLineRawString(quoteChar, start); | 1632 return _tokenizeMultiLineRawString(quoteChar, start); |
| 1633 } | 1633 } |
| 1634 int next = _reader.advance(); | 1634 int next = _reader.advance(); |
| 1635 while (next != -1) { | 1635 while (next != -1) { |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1674 next = _reader.advance(); | 1674 next = _reader.advance(); |
| 1675 } | 1675 } |
| 1676 recordStartOfLine(); | 1676 recordStartOfLine(); |
| 1677 } else if (next == 0xA) { | 1677 } else if (next == 0xA) { |
| 1678 recordStartOfLine(); | 1678 recordStartOfLine(); |
| 1679 next = _reader.advance(); | 1679 next = _reader.advance(); |
| 1680 } else { | 1680 } else { |
| 1681 next = _reader.advance(); | 1681 next = _reader.advance(); |
| 1682 } | 1682 } |
| 1683 } | 1683 } |
| 1684 _reportError(ScannerErrorCode.UNTERMINATED_STRING_LITERAL, []); | 1684 _reportError(ScannerErrorCode.UNTERMINATED_STRING_LITERAL); |
| 1685 if (start == _reader.offset) { | 1685 if (start == _reader.offset) { |
| 1686 _appendStringTokenWithOffset(TokenType.STRING, "", 1); | 1686 _appendStringTokenWithOffset(TokenType.STRING, "", 1); |
| 1687 } else { | 1687 } else { |
| 1688 _appendStringToken(TokenType.STRING, _reader.getString(start, 0)); | 1688 _appendStringToken(TokenType.STRING, _reader.getString(start, 0)); |
| 1689 } | 1689 } |
| 1690 return _reader.advance(); | 1690 return _reader.advance(); |
| 1691 } | 1691 } |
| 1692 | 1692 |
| 1693 int _tokenizeMultiply(int next) => _select(0x3D, TokenType.STAR_EQ, TokenType.
STAR); | 1693 int _tokenizeMultiply(int next) => _select(0x3D, TokenType.STAR_EQ, TokenType.
STAR); |
| 1694 | 1694 |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1750 } | 1750 } |
| 1751 } | 1751 } |
| 1752 | 1752 |
| 1753 int _tokenizeSingleLineRawString(int next, int quoteChar, int start) { | 1753 int _tokenizeSingleLineRawString(int next, int quoteChar, int start) { |
| 1754 next = _reader.advance(); | 1754 next = _reader.advance(); |
| 1755 while (next != -1) { | 1755 while (next != -1) { |
| 1756 if (next == quoteChar) { | 1756 if (next == quoteChar) { |
| 1757 _appendStringToken(TokenType.STRING, _reader.getString(start, 0)); | 1757 _appendStringToken(TokenType.STRING, _reader.getString(start, 0)); |
| 1758 return _reader.advance(); | 1758 return _reader.advance(); |
| 1759 } else if (next == 0xD || next == 0xA) { | 1759 } else if (next == 0xD || next == 0xA) { |
| 1760 _reportError(ScannerErrorCode.UNTERMINATED_STRING_LITERAL, []); | 1760 _reportError(ScannerErrorCode.UNTERMINATED_STRING_LITERAL); |
| 1761 _appendStringToken(TokenType.STRING, _reader.getString(start, -1)); | 1761 _appendStringToken(TokenType.STRING, _reader.getString(start, -1)); |
| 1762 return _reader.advance(); | 1762 return _reader.advance(); |
| 1763 } | 1763 } |
| 1764 next = _reader.advance(); | 1764 next = _reader.advance(); |
| 1765 } | 1765 } |
| 1766 _reportError(ScannerErrorCode.UNTERMINATED_STRING_LITERAL, []); | 1766 _reportError(ScannerErrorCode.UNTERMINATED_STRING_LITERAL); |
| 1767 _appendStringToken(TokenType.STRING, _reader.getString(start, 0)); | 1767 _appendStringToken(TokenType.STRING, _reader.getString(start, 0)); |
| 1768 return _reader.advance(); | 1768 return _reader.advance(); |
| 1769 } | 1769 } |
| 1770 | 1770 |
| 1771 int _tokenizeSingleLineString(int next, int quoteChar, int start) { | 1771 int _tokenizeSingleLineString(int next, int quoteChar, int start) { |
| 1772 while (next != quoteChar) { | 1772 while (next != quoteChar) { |
| 1773 if (next == 0x5C) { | 1773 if (next == 0x5C) { |
| 1774 next = _reader.advance(); | 1774 next = _reader.advance(); |
| 1775 } else if (next == 0x24) { | 1775 } else if (next == 0x24) { |
| 1776 _appendStringToken(TokenType.STRING, _reader.getString(start, -1)); | 1776 _appendStringToken(TokenType.STRING, _reader.getString(start, -1)); |
| 1777 next = _tokenizeStringInterpolation(start); | 1777 next = _tokenizeStringInterpolation(start); |
| 1778 _beginToken(); | 1778 _beginToken(); |
| 1779 start = _reader.offset; | 1779 start = _reader.offset; |
| 1780 continue; | 1780 continue; |
| 1781 } | 1781 } |
| 1782 if (next <= 0xD && (next == 0xA || next == 0xD || next == -1)) { | 1782 if (next <= 0xD && (next == 0xA || next == 0xD || next == -1)) { |
| 1783 _reportError(ScannerErrorCode.UNTERMINATED_STRING_LITERAL, []); | 1783 _reportError(ScannerErrorCode.UNTERMINATED_STRING_LITERAL); |
| 1784 if (start == _reader.offset) { | 1784 if (start == _reader.offset) { |
| 1785 _appendStringTokenWithOffset(TokenType.STRING, "", 1); | 1785 _appendStringTokenWithOffset(TokenType.STRING, "", 1); |
| 1786 } else if (next == -1) { | 1786 } else if (next == -1) { |
| 1787 _appendStringToken(TokenType.STRING, _reader.getString(start, 0)); | 1787 _appendStringToken(TokenType.STRING, _reader.getString(start, 0)); |
| 1788 } else { | 1788 } else { |
| 1789 _appendStringToken(TokenType.STRING, _reader.getString(start, -1)); | 1789 _appendStringToken(TokenType.STRING, _reader.getString(start, -1)); |
| 1790 } | 1790 } |
| 1791 return _reader.advance(); | 1791 return _reader.advance(); |
| 1792 } | 1792 } |
| 1793 next = _reader.advance(); | 1793 next = _reader.advance(); |
| (...skipping 889 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2683 * @param precedingComment the first comment in the list of comments that prec
ede this token | 2683 * @param precedingComment the first comment in the list of comments that prec
ede this token |
| 2684 */ | 2684 */ |
| 2685 TokenWithComment(TokenType type, int offset, this._precedingComment) : super(t
ype, offset); | 2685 TokenWithComment(TokenType type, int offset, this._precedingComment) : super(t
ype, offset); |
| 2686 | 2686 |
| 2687 @override | 2687 @override |
| 2688 Token copy() => new TokenWithComment(type, offset, _precedingComment); | 2688 Token copy() => new TokenWithComment(type, offset, _precedingComment); |
| 2689 | 2689 |
| 2690 @override | 2690 @override |
| 2691 Token get precedingComments => _precedingComment; | 2691 Token get precedingComments => _precedingComment; |
| 2692 } | 2692 } |
| OLD | NEW |