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

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

Issue 23769004: java2dart improvement - use field if getter/setter are trivial. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 3 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 // This code was auto-generated, is not intended to be edited, and is subject to 1 // This code was auto-generated, is not intended to be edited, and is subject to
2 // significant change. Please see the README file for more information. 2 // significant change. Please see the README file for more information.
3 library engine.scanner; 3 library engine.scanner;
4 import 'dart:collection'; 4 import 'dart:collection';
5 import 'java_core.dart'; 5 import 'java_core.dart';
6 import 'java_engine.dart'; 6 import 'java_engine.dart';
7 import 'source.dart'; 7 import 'source.dart';
8 import 'error.dart'; 8 import 'error.dart';
9 import 'instrumentation.dart'; 9 import 'instrumentation.dart';
10 /** 10 /**
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after
313 LIBRARY, 313 LIBRARY,
314 OPERATOR, 314 OPERATOR,
315 PART, 315 PART,
316 SET, 316 SET,
317 STATIC, 317 STATIC,
318 TYPEDEF]; 318 TYPEDEF];
319 319
320 /** 320 /**
321 * The lexeme for the keyword. 321 * The lexeme for the keyword.
322 */ 322 */
323 String _syntax; 323 String syntax;
324 324
325 /** 325 /**
326 * A flag indicating whether the keyword is a pseudo-keyword. Pseudo keywords can be used as 326 * A flag indicating whether the keyword is a pseudo-keyword. Pseudo keywords can be used as
327 * identifiers. 327 * identifiers.
328 */ 328 */
329 bool _isPseudoKeyword2 = false; 329 bool isPseudoKeyword = false;
330 330
331 /** 331 /**
332 * A table mapping the lexemes of keywords to the corresponding keyword. 332 * A table mapping the lexemes of keywords to the corresponding keyword.
333 */ 333 */
334 static Map<String, Keyword> keywords = createKeywordMap(); 334 static Map<String, Keyword> keywords = createKeywordMap();
335 335
336 /** 336 /**
337 * Create a table mapping the lexemes of keywords to the corresponding keyword . 337 * Create a table mapping the lexemes of keywords to the corresponding keyword .
338 * 338 *
339 * @return the table that was created 339 * @return the table that was created
340 */ 340 */
341 static Map<String, Keyword> createKeywordMap() { 341 static Map<String, Keyword> createKeywordMap() {
342 LinkedHashMap<String, Keyword> result = new LinkedHashMap<String, Keyword>() ; 342 LinkedHashMap<String, Keyword> result = new LinkedHashMap<String, Keyword>() ;
343 for (Keyword keyword in values) { 343 for (Keyword keyword in values) {
344 result[keyword._syntax] = keyword; 344 result[keyword.syntax] = keyword;
345 } 345 }
346 return result; 346 return result;
347 } 347 }
348 348
349 /** 349 /**
350 * Initialize a newly created keyword to have the given syntax. The keyword is not a 350 * Initialize a newly created keyword to have the given syntax. The keyword is not a
351 * pseudo-keyword. 351 * pseudo-keyword.
352 * 352 *
353 * @param syntax the lexeme for the keyword 353 * @param syntax the lexeme for the keyword
354 */ 354 */
355 Keyword.con1(String name, int ordinal, String syntax) : this.con2(name, ordina l, syntax, false); 355 Keyword.con1(String name, int ordinal, String syntax) : this.con2(name, ordina l, syntax, false);
356 356
357 /** 357 /**
358 * Initialize a newly created keyword to have the given syntax. The keyword is a pseudo-keyword if 358 * Initialize a newly created keyword to have the given syntax. The keyword is a pseudo-keyword if
359 * the given flag is `true`. 359 * the given flag is `true`.
360 * 360 *
361 * @param syntax the lexeme for the keyword 361 * @param syntax the lexeme for the keyword
362 * @param isPseudoKeyword `true` if this keyword is a pseudo-keyword 362 * @param isPseudoKeyword `true` if this keyword is a pseudo-keyword
363 */ 363 */
364 Keyword.con2(String name, int ordinal, String syntax, bool isPseudoKeyword) : super(name, ordinal) { 364 Keyword.con2(String name, int ordinal, String syntax, bool isPseudoKeyword) : super(name, ordinal) {
365 this._syntax = syntax; 365 this.syntax = syntax;
366 this._isPseudoKeyword2 = isPseudoKeyword; 366 this.isPseudoKeyword = isPseudoKeyword;
367 } 367 }
368
369 /**
370 * Return the lexeme for the keyword.
371 *
372 * @return the lexeme for the keyword
373 */
374 String get syntax => _syntax;
375
376 /**
377 * Return `true` if this keyword is a pseudo-keyword. Pseudo keywords can be u sed as
378 * identifiers.
379 *
380 * @return `true` if this keyword is a pseudo-keyword
381 */
382 bool get isPseudoKeyword => _isPseudoKeyword2;
383 } 368 }
384 /** 369 /**
385 * The abstract class `AbstractScanner` implements a scanner for Dart code. Subc lasses are 370 * The abstract class `AbstractScanner` implements a scanner for Dart code. Subc lasses are
386 * required to implement the interface used to access the characters being scann ed. 371 * required to implement the interface used to access the characters being scann ed.
387 * 372 *
388 * The lexical structure of Dart is ambiguous without knowledge of the context i n which a token is 373 * The lexical structure of Dart is ambiguous without knowledge of the context i n which a token is
389 * being scanned. For example, without context we cannot determine whether sourc e of the form "<<" 374 * being scanned. For example, without context we cannot determine whether sourc e of the form "<<"
390 * should be scanned as a single left-shift operator or as two left angle bracke ts. This scanner 375 * should be scanned as a single left-shift operator or as two left angle bracke ts. This scanner
391 * does not have any context, so it always resolves such conflicts by scanning t he longest possible 376 * does not have any context, so it always resolves such conflicts by scanning t he longest possible
392 * token. 377 * token.
393 * 378 *
394 * @coverage dart.engine.parser 379 * @coverage dart.engine.parser
395 */ 380 */
396 abstract class AbstractScanner { 381 abstract class AbstractScanner {
397 382
398 /** 383 /**
399 * The source being scanned. 384 * The source being scanned.
400 */ 385 */
401 Source _source; 386 Source source;
402 387
403 /** 388 /**
404 * The error listener that will be informed of any errors that are found durin g the scan. 389 * The error listener that will be informed of any errors that are found durin g the scan.
405 */ 390 */
406 AnalysisErrorListener _errorListener; 391 AnalysisErrorListener _errorListener;
407 392
408 /** 393 /**
409 * The token pointing to the head of the linked list of tokens. 394 * The token pointing to the head of the linked list of tokens.
410 */ 395 */
411 Token _tokens; 396 Token _tokens;
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
446 */ 431 */
447 bool _hasUnmatchedGroups2 = false; 432 bool _hasUnmatchedGroups2 = false;
448 433
449 /** 434 /**
450 * Initialize a newly created scanner. 435 * Initialize a newly created scanner.
451 * 436 *
452 * @param source the source being scanned 437 * @param source the source being scanned
453 * @param errorListener the error listener that will be informed of any errors that are found 438 * @param errorListener the error listener that will be informed of any errors that are found
454 */ 439 */
455 AbstractScanner(Source source, AnalysisErrorListener errorListener) { 440 AbstractScanner(Source source, AnalysisErrorListener errorListener) {
456 this._source = source; 441 this.source = source;
457 this._errorListener = errorListener; 442 this._errorListener = errorListener;
458 _tokens = new Token(TokenType.EOF, -1); 443 _tokens = new Token(TokenType.EOF, -1);
459 _tokens.setNext(_tokens); 444 _tokens.setNext(_tokens);
460 _tail = _tokens; 445 _tail = _tokens;
461 _tokenStart = -1; 446 _tokenStart = -1;
462 _lineStarts.add(0); 447 _lineStarts.add(0);
463 } 448 }
464 449
465 /** 450 /**
466 * Return an array containing the offsets of the first character of each line in the source code. 451 * Return an array containing the offsets of the first character of each line in the source code.
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after
798 } 783 }
799 _hasUnmatchedGroups2 = true; 784 _hasUnmatchedGroups2 = true;
800 _groupingStack.removeAt(last); 785 _groupingStack.removeAt(last);
801 last--; 786 last--;
802 } 787 }
803 return null; 788 return null;
804 } 789 }
805 Token firstToken() => _tokens.next; 790 Token firstToken() => _tokens.next;
806 791
807 /** 792 /**
808 * Return the source being scanned.
809 *
810 * @return the source being scanned
811 */
812 Source get source => _source;
813
814 /**
815 * Report an error at the current offset. 793 * Report an error at the current offset.
816 * 794 *
817 * @param errorCode the error code indicating the nature of the error 795 * @param errorCode the error code indicating the nature of the error
818 * @param arguments any arguments needed to complete the error message 796 * @param arguments any arguments needed to complete the error message
819 */ 797 */
820 void reportError(ScannerErrorCode errorCode, List<Object> arguments) { 798 void reportError(ScannerErrorCode errorCode, List<Object> arguments) {
821 _errorListener.onError(new AnalysisError.con2(source, offset, 1, errorCode, arguments)); 799 _errorListener.onError(new AnalysisError.con2(source, offset, 1, errorCode, arguments));
822 } 800 }
823 int select(int choice, TokenType yesType, TokenType noType) { 801 int select(int choice, TokenType yesType, TokenType noType) {
824 int next = advance(); 802 int next = advance();
(...skipping 624 matching lines...) Expand 10 before | Expand all | Expand 10 after
1449 * Instances of the class `Token` represent a token that was scanned from the in put. Each 1427 * Instances of the class `Token` represent a token that was scanned from the in put. Each
1450 * token knows which token follows it, acting as the head of a linked list of to kens. 1428 * token knows which token follows it, acting as the head of a linked list of to kens.
1451 * 1429 *
1452 * @coverage dart.engine.parser 1430 * @coverage dart.engine.parser
1453 */ 1431 */
1454 class Token { 1432 class Token {
1455 1433
1456 /** 1434 /**
1457 * The type of the token. 1435 * The type of the token.
1458 */ 1436 */
1459 TokenType _type; 1437 TokenType type;
1460 1438
1461 /** 1439 /**
1462 * The offset from the beginning of the file to the first character in the tok en. 1440 * The offset from the beginning of the file to the first character in the tok en.
1463 */ 1441 */
1464 int _offset = 0; 1442 int offset = 0;
1465 1443
1466 /** 1444 /**
1467 * The previous token in the token stream. 1445 * The previous token in the token stream.
1468 */ 1446 */
1469 Token _previous; 1447 Token previous;
1470 1448
1471 /** 1449 /**
1472 * The next token in the token stream. 1450 * The next token in the token stream.
1473 */ 1451 */
1474 Token _next; 1452 Token next;
1475 1453
1476 /** 1454 /**
1477 * Initialize a newly created token to have the given type and offset. 1455 * Initialize a newly created token to have the given type and offset.
1478 * 1456 *
1479 * @param type the type of the token 1457 * @param type the type of the token
1480 * @param offset the offset from the beginning of the file to the first charac ter in the token 1458 * @param offset the offset from the beginning of the file to the first charac ter in the token
1481 */ 1459 */
1482 Token(TokenType type, int offset) { 1460 Token(TokenType type, int offset) {
1483 this._type = type; 1461 this.type = type;
1484 this._offset = offset; 1462 this.offset = offset;
1485 } 1463 }
1486 1464
1487 /** 1465 /**
1488 * Return the offset from the beginning of the file to the character after las t character of the 1466 * Return the offset from the beginning of the file to the character after las t character of the
1489 * token. 1467 * token.
1490 * 1468 *
1491 * @return the offset from the beginning of the file to the first character af ter last character 1469 * @return the offset from the beginning of the file to the first character af ter last character
1492 * of the token 1470 * of the token
1493 */ 1471 */
1494 int get end => _offset + length; 1472 int get end => offset + length;
1495 1473
1496 /** 1474 /**
1497 * Return the number of characters in the node's source range. 1475 * Return the number of characters in the node's source range.
1498 * 1476 *
1499 * @return the number of characters in the node's source range 1477 * @return the number of characters in the node's source range
1500 */ 1478 */
1501 int get length => lexeme.length; 1479 int get length => lexeme.length;
1502 1480
1503 /** 1481 /**
1504 * Return the lexeme that represents this token. 1482 * Return the lexeme that represents this token.
1505 * 1483 *
1506 * @return the lexeme that represents this token 1484 * @return the lexeme that represents this token
1507 */ 1485 */
1508 String get lexeme => _type.lexeme; 1486 String get lexeme => type.lexeme;
1509
1510 /**
1511 * Return the next token in the token stream.
1512 *
1513 * @return the next token in the token stream
1514 */
1515 Token get next => _next;
1516
1517 /**
1518 * Return the offset from the beginning of the file to the first character in the token.
1519 *
1520 * @return the offset from the beginning of the file to the first character in the token
1521 */
1522 int get offset => _offset;
1523 1487
1524 /** 1488 /**
1525 * Return the first comment in the list of comments that precede this token, o r `null` if 1489 * Return the first comment in the list of comments that precede this token, o r `null` if
1526 * there are no comments preceding this token. Additional comments can be reac hed by following the 1490 * there are no comments preceding this token. Additional comments can be reac hed by following the
1527 * token stream using [getNext] until `null` is returned. 1491 * token stream using [getNext] until `null` is returned.
1528 * 1492 *
1529 * @return the first comment in the list of comments that precede this token 1493 * @return the first comment in the list of comments that precede this token
1530 */ 1494 */
1531 Token get precedingComments => null; 1495 Token get precedingComments => null;
1532 1496
1533 /** 1497 /**
1534 * Return the previous token in the token stream.
1535 *
1536 * @return the previous token in the token stream
1537 */
1538 Token get previous => _previous;
1539
1540 /**
1541 * Return the type of the token.
1542 *
1543 * @return the type of the token
1544 */
1545 TokenType get type => _type;
1546
1547 /**
1548 * Return `true` if this token represents an operator. 1498 * Return `true` if this token represents an operator.
1549 * 1499 *
1550 * @return `true` if this token represents an operator 1500 * @return `true` if this token represents an operator
1551 */ 1501 */
1552 bool get isOperator => _type.isOperator; 1502 bool get isOperator => type.isOperator;
1553 1503
1554 /** 1504 /**
1555 * Return `true` if this token is a synthetic token. A synthetic token is a to ken that was 1505 * Return `true` if this token is a synthetic token. A synthetic token is a to ken that was
1556 * introduced by the parser in order to recover from an error in the code. Syn thetic tokens always 1506 * introduced by the parser in order to recover from an error in the code. Syn thetic tokens always
1557 * have a length of zero (`0`). 1507 * have a length of zero (`0`).
1558 * 1508 *
1559 * @return `true` if this token is a synthetic token 1509 * @return `true` if this token is a synthetic token
1560 */ 1510 */
1561 bool get isSynthetic => length == 0; 1511 bool get isSynthetic => length == 0;
1562 1512
1563 /** 1513 /**
1564 * Return `true` if this token represents an operator that can be defined by u sers. 1514 * Return `true` if this token represents an operator that can be defined by u sers.
1565 * 1515 *
1566 * @return `true` if this token represents an operator that can be defined by users 1516 * @return `true` if this token represents an operator that can be defined by users
1567 */ 1517 */
1568 bool get isUserDefinableOperator => _type.isUserDefinableOperator; 1518 bool get isUserDefinableOperator => type.isUserDefinableOperator;
1569 1519
1570 /** 1520 /**
1571 * Set the next token in the token stream to the given token. This has the sid e-effect of setting 1521 * Set the next token in the token stream to the given token. This has the sid e-effect of setting
1572 * this token to be the previous token for the given token. 1522 * this token to be the previous token for the given token.
1573 * 1523 *
1574 * @param token the next token in the token stream 1524 * @param token the next token in the token stream
1575 * @return the token that was passed in 1525 * @return the token that was passed in
1576 */ 1526 */
1577 Token setNext(Token token) { 1527 Token setNext(Token token) {
1578 _next = token; 1528 next = token;
1579 token.previous = this; 1529 token.previous = this;
1580 return token; 1530 return token;
1581 } 1531 }
1582 1532
1583 /** 1533 /**
1584 * Set the next token in the token stream to the given token without changing which token is the 1534 * Set the next token in the token stream to the given token without changing which token is the
1585 * previous token for the given token. 1535 * previous token for the given token.
1586 * 1536 *
1587 * @param token the next token in the token stream 1537 * @param token the next token in the token stream
1588 * @return the token that was passed in 1538 * @return the token that was passed in
1589 */ 1539 */
1590 Token setNextWithoutSettingPrevious(Token token) { 1540 Token setNextWithoutSettingPrevious(Token token) {
1591 _next = token; 1541 next = token;
1592 return token; 1542 return token;
1593 } 1543 }
1594
1595 /**
1596 * Set the offset from the beginning of the file to the first character in the token to the given
1597 * offset.
1598 *
1599 * @param offset the offset from the beginning of the file to the first charac ter in the token
1600 */
1601 void set offset(int offset2) {
1602 this._offset = offset2;
1603 }
1604 String toString() => lexeme; 1544 String toString() => lexeme;
1605 1545
1606 /** 1546 /**
1607 * Return the value of this token. For keyword tokens, this is the keyword ass ociated with the 1547 * Return the value of this token. For keyword tokens, this is the keyword ass ociated with the
1608 * token, for other tokens it is the lexeme associated with the token. 1548 * token, for other tokens it is the lexeme associated with the token.
1609 * 1549 *
1610 * @return the value of this token 1550 * @return the value of this token
1611 */ 1551 */
1612 Object value() => _type.lexeme; 1552 Object value() => type.lexeme;
1613
1614 /**
1615 * Set the previous token in the token stream to the given token.
1616 *
1617 * @param previous the previous token in the token stream
1618 */
1619 void set previous(Token previous2) {
1620 this._previous = previous2;
1621 }
1622 } 1553 }
1623 /** 1554 /**
1624 * Instances of the class `StringScanner` implement a scanner that reads from a string. The 1555 * Instances of the class `StringScanner` implement a scanner that reads from a string. The
1625 * scanning logic is in the superclass. 1556 * scanning logic is in the superclass.
1626 * 1557 *
1627 * @coverage dart.engine.parser 1558 * @coverage dart.engine.parser
1628 */ 1559 */
1629 class StringScanner extends AbstractScanner { 1560 class StringScanner extends AbstractScanner {
1630 1561
1631 /** 1562 /**
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
1731 /** 1662 /**
1732 * Instances of the class `KeywordToken` represent a keyword in the language. 1663 * Instances of the class `KeywordToken` represent a keyword in the language.
1733 * 1664 *
1734 * @coverage dart.engine.parser 1665 * @coverage dart.engine.parser
1735 */ 1666 */
1736 class KeywordToken extends Token { 1667 class KeywordToken extends Token {
1737 1668
1738 /** 1669 /**
1739 * The keyword being represented by this token. 1670 * The keyword being represented by this token.
1740 */ 1671 */
1741 Keyword _keyword; 1672 Keyword keyword;
1742 1673
1743 /** 1674 /**
1744 * Initialize a newly created token to represent the given keyword. 1675 * Initialize a newly created token to represent the given keyword.
1745 * 1676 *
1746 * @param keyword the keyword being represented by this token 1677 * @param keyword the keyword being represented by this token
1747 * @param offset the offset from the beginning of the file to the first charac ter in the token 1678 * @param offset the offset from the beginning of the file to the first charac ter in the token
1748 */ 1679 */
1749 KeywordToken(Keyword keyword, int offset) : super(TokenType.KEYWORD, offset) { 1680 KeywordToken(Keyword keyword, int offset) : super(TokenType.KEYWORD, offset) {
1750 this._keyword = keyword; 1681 this.keyword = keyword;
1751 } 1682 }
1752 1683 String get lexeme => keyword.syntax;
1753 /** 1684 Keyword value() => keyword;
1754 * Return the keyword being represented by this token.
1755 *
1756 * @return the keyword being represented by this token
1757 */
1758 Keyword get keyword => _keyword;
1759 String get lexeme => _keyword.syntax;
1760 Keyword value() => _keyword;
1761 } 1685 }
1762 /** 1686 /**
1763 * Instances of the class `BeginToken` represent the opening half of a grouping pair of 1687 * Instances of the class `BeginToken` represent the opening half of a grouping pair of
1764 * tokens. This is used for curly brackets ('{'), parentheses ('('), and square brackets ('['). 1688 * tokens. This is used for curly brackets ('{'), parentheses ('('), and square brackets ('[').
1765 * 1689 *
1766 * @coverage dart.engine.parser 1690 * @coverage dart.engine.parser
1767 */ 1691 */
1768 class BeginToken extends Token { 1692 class BeginToken extends Token {
1769 1693
1770 /** 1694 /**
1771 * The token that corresponds to this token. 1695 * The token that corresponds to this token.
1772 */ 1696 */
1773 Token _endToken; 1697 Token endToken;
1774 1698
1775 /** 1699 /**
1776 * Initialize a newly created token representing the opening half of a groupin g pair of tokens. 1700 * Initialize a newly created token representing the opening half of a groupin g pair of tokens.
1777 * 1701 *
1778 * @param type the type of the token 1702 * @param type the type of the token
1779 * @param offset the offset from the beginning of the file to the first charac ter in the token 1703 * @param offset the offset from the beginning of the file to the first charac ter in the token
1780 */ 1704 */
1781 BeginToken(TokenType type, int offset) : super(type, offset) { 1705 BeginToken(TokenType type, int offset) : super(type, offset) {
1782 assert((identical(type, TokenType.OPEN_CURLY_BRACKET) || identical(type, Tok enType.OPEN_PAREN) || identical(type, TokenType.OPEN_SQUARE_BRACKET) || identica l(type, TokenType.STRING_INTERPOLATION_EXPRESSION))); 1706 assert((identical(type, TokenType.OPEN_CURLY_BRACKET) || identical(type, Tok enType.OPEN_PAREN) || identical(type, TokenType.OPEN_SQUARE_BRACKET) || identica l(type, TokenType.STRING_INTERPOLATION_EXPRESSION)));
1783 } 1707 }
1784
1785 /**
1786 * Return the token that corresponds to this token.
1787 *
1788 * @return the token that corresponds to this token
1789 */
1790 Token get endToken => _endToken;
1791
1792 /**
1793 * Set the token that corresponds to this token to the given token.
1794 *
1795 * @param token the token that corresponds to this token
1796 */
1797 void set endToken(Token token) {
1798 this._endToken = token;
1799 }
1800 } 1708 }
1801 /** 1709 /**
1802 * The enumeration `TokenClass` represents classes (or groups) of tokens with a similar use. 1710 * The enumeration `TokenClass` represents classes (or groups) of tokens with a similar use.
1803 * 1711 *
1804 * @coverage dart.engine.parser 1712 * @coverage dart.engine.parser
1805 */ 1713 */
1806 class TokenClass extends Enum<TokenClass> { 1714 class TokenClass extends Enum<TokenClass> {
1807 1715
1808 /** 1716 /**
1809 * A value used to indicate that the token type is not part of any specific cl ass of token. 1717 * A value used to indicate that the token type is not part of any specific cl ass of token.
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
1899 MULTIPLICATIVE_OPERATOR, 1807 MULTIPLICATIVE_OPERATOR,
1900 RELATIONAL_OPERATOR, 1808 RELATIONAL_OPERATOR,
1901 SHIFT_OPERATOR, 1809 SHIFT_OPERATOR,
1902 UNARY_POSTFIX_OPERATOR, 1810 UNARY_POSTFIX_OPERATOR,
1903 UNARY_PREFIX_OPERATOR]; 1811 UNARY_PREFIX_OPERATOR];
1904 1812
1905 /** 1813 /**
1906 * The precedence of tokens of this class, or `0` if the such tokens do not re present an 1814 * The precedence of tokens of this class, or `0` if the such tokens do not re present an
1907 * operator. 1815 * operator.
1908 */ 1816 */
1909 int _precedence = 0; 1817 int precedence = 0;
1910 TokenClass.con1(String name, int ordinal) : this.con2(name, ordinal, 0); 1818 TokenClass.con1(String name, int ordinal) : this.con2(name, ordinal, 0);
1911 TokenClass.con2(String name, int ordinal, int precedence) : super(name, ordina l) { 1819 TokenClass.con2(String name, int ordinal, int precedence) : super(name, ordina l) {
1912 this._precedence = precedence; 1820 this.precedence = precedence;
1913 } 1821 }
1914
1915 /**
1916 * Return the precedence of tokens of this class, or `0` if the such tokens do not represent
1917 * an operator.
1918 *
1919 * @return the precedence of tokens of this class
1920 */
1921 int get precedence => _precedence;
1922 } 1822 }
1923 /** 1823 /**
1924 * Instances of the class `KeywordTokenWithComment` implement a keyword token th at is preceded 1824 * Instances of the class `KeywordTokenWithComment` implement a keyword token th at is preceded
1925 * by comments. 1825 * by comments.
1926 * 1826 *
1927 * @coverage dart.engine.parser 1827 * @coverage dart.engine.parser
1928 */ 1828 */
1929 class KeywordTokenWithComment extends KeywordToken { 1829 class KeywordTokenWithComment extends KeywordToken {
1930 1830
1931 /** 1831 /**
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
2097 1997
2098 /** 1998 /**
2099 * The class of the token. 1999 * The class of the token.
2100 */ 2000 */
2101 TokenClass _tokenClass; 2001 TokenClass _tokenClass;
2102 2002
2103 /** 2003 /**
2104 * The lexeme that defines this type of token, or `null` if there is more than one possible 2004 * The lexeme that defines this type of token, or `null` if there is more than one possible
2105 * lexeme for this type of token. 2005 * lexeme for this type of token.
2106 */ 2006 */
2107 String _lexeme; 2007 String lexeme;
2108 TokenType.con1(String name, int ordinal) : this.con2(name, ordinal, TokenClass .NO_CLASS, null); 2008 TokenType.con1(String name, int ordinal) : this.con2(name, ordinal, TokenClass .NO_CLASS, null);
2109 TokenType.con2(String name, int ordinal, TokenClass tokenClass, String lexeme) : super(name, ordinal) { 2009 TokenType.con2(String name, int ordinal, TokenClass tokenClass, String lexeme) : super(name, ordinal) {
2110 this._tokenClass = tokenClass == null ? TokenClass.NO_CLASS : tokenClass; 2010 this._tokenClass = tokenClass == null ? TokenClass.NO_CLASS : tokenClass;
2111 this._lexeme = lexeme; 2011 this.lexeme = lexeme;
2112 } 2012 }
2113 2013
2114 /** 2014 /**
2115 * Return the lexeme that defines this type of token, or `null` if there is mo re than one
2116 * possible lexeme for this type of token.
2117 *
2118 * @return the lexeme that defines this type of token
2119 */
2120 String get lexeme => _lexeme;
2121
2122 /**
2123 * Return the precedence of the token, or `0` if the token does not represent an operator. 2015 * Return the precedence of the token, or `0` if the token does not represent an operator.
2124 * 2016 *
2125 * @return the precedence of the token 2017 * @return the precedence of the token
2126 */ 2018 */
2127 int get precedence => _tokenClass.precedence; 2019 int get precedence => _tokenClass.precedence;
2128 2020
2129 /** 2021 /**
2130 * Return `true` if this type of token represents an additive operator. 2022 * Return `true` if this type of token represents an additive operator.
2131 * 2023 *
2132 * @return `true` if this type of token represents an additive operator 2024 * @return `true` if this type of token represents an additive operator
(...skipping 26 matching lines...) Expand all
2159 * 2051 *
2160 * @return `true` if this type of token represents an equality operator 2052 * @return `true` if this type of token represents an equality operator
2161 */ 2053 */
2162 bool get isEqualityOperator => identical(_tokenClass, TokenClass.EQUALITY_OPER ATOR); 2054 bool get isEqualityOperator => identical(_tokenClass, TokenClass.EQUALITY_OPER ATOR);
2163 2055
2164 /** 2056 /**
2165 * Return `true` if this type of token represents an increment operator. 2057 * Return `true` if this type of token represents an increment operator.
2166 * 2058 *
2167 * @return `true` if this type of token represents an increment operator 2059 * @return `true` if this type of token represents an increment operator
2168 */ 2060 */
2169 bool get isIncrementOperator => identical(_lexeme, "++") || identical(_lexeme, "--"); 2061 bool get isIncrementOperator => identical(lexeme, "++") || identical(lexeme, " --");
2170 2062
2171 /** 2063 /**
2172 * Return `true` if this type of token represents a multiplicative operator. 2064 * Return `true` if this type of token represents a multiplicative operator.
2173 * 2065 *
2174 * @return `true` if this type of token represents a multiplicative operator 2066 * @return `true` if this type of token represents a multiplicative operator
2175 */ 2067 */
2176 bool get isMultiplicativeOperator => identical(_tokenClass, TokenClass.MULTIPL ICATIVE_OPERATOR); 2068 bool get isMultiplicativeOperator => identical(_tokenClass, TokenClass.MULTIPL ICATIVE_OPERATOR);
2177 2069
2178 /** 2070 /**
2179 * Return `true` if this token type represents an operator. 2071 * Return `true` if this token type represents an operator.
(...skipping 28 matching lines...) Expand all
2208 * 2100 *
2209 * @return `true` if this type of token represents a unary prefix operator 2101 * @return `true` if this type of token represents a unary prefix operator
2210 */ 2102 */
2211 bool get isUnaryPrefixOperator => identical(_tokenClass, TokenClass.UNARY_PREF IX_OPERATOR); 2103 bool get isUnaryPrefixOperator => identical(_tokenClass, TokenClass.UNARY_PREF IX_OPERATOR);
2212 2104
2213 /** 2105 /**
2214 * Return `true` if this token type represents an operator that can be defined by users. 2106 * Return `true` if this token type represents an operator that can be defined by users.
2215 * 2107 *
2216 * @return `true` if this token type represents an operator that can be define d by users 2108 * @return `true` if this token type represents an operator that can be define d by users
2217 */ 2109 */
2218 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, "|"); 2110 bool get isUserDefinableOperator => identical(lexeme, "==") || identical(lexem e, "~") || identical(lexeme, "[]") || identical(lexeme, "[]=") || identical(lexe me, "*") || identical(lexeme, "/") || identical(lexeme, "%") || identical(lexeme , "~/") || identical(lexeme, "+") || identical(lexeme, "-") || identical(lexeme, "<<") || identical(lexeme, ">>") || identical(lexeme, ">=") || identical(lexeme , ">") || identical(lexeme, "<=") || identical(lexeme, "<") || identical(lexeme, "&") || identical(lexeme, "^") || identical(lexeme, "|");
2219 } 2111 }
2220 class TokenType_EOF extends TokenType { 2112 class TokenType_EOF extends TokenType {
2221 TokenType_EOF(String name, int ordinal, TokenClass arg0, String arg1) : super. con2(name, ordinal, arg0, arg1); 2113 TokenType_EOF(String name, int ordinal, TokenClass arg0, String arg1) : super. con2(name, ordinal, arg0, arg1);
2222 String toString() => "-eof-"; 2114 String toString() => "-eof-";
2223 } 2115 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698