| Index: pkg/front_end/lib/src/fasta/scanner/abstract_scanner.dart
|
| diff --git a/pkg/front_end/lib/src/fasta/scanner/abstract_scanner.dart b/pkg/front_end/lib/src/fasta/scanner/abstract_scanner.dart
|
| index 9da897600e55d6798279a9efa6fc2ee9de8c00e6..cfccd631bb009729793726939b217c09d979c01a 100644
|
| --- a/pkg/front_end/lib/src/fasta/scanner/abstract_scanner.dart
|
| +++ b/pkg/front_end/lib/src/fasta/scanner/abstract_scanner.dart
|
| @@ -17,8 +17,6 @@ import 'error_token.dart' show UnterminatedToken;
|
|
|
| import 'keyword_state.dart' show KeywordState;
|
|
|
| -import 'precedence.dart';
|
| -
|
| import 'token.dart'
|
| show BeginGroupToken, CommentToken, DartDocToken, SymbolToken, Token;
|
|
|
| @@ -273,16 +271,16 @@ abstract class AbstractScanner implements Scanner {
|
| }
|
|
|
| if (identical(next, $CLOSE_PAREN)) {
|
| - return appendEndGroup(CLOSE_PAREN_INFO, OPEN_PAREN_TOKEN);
|
| + return appendEndGroup(TokenType.CLOSE_PAREN, OPEN_PAREN_TOKEN);
|
| }
|
|
|
| if (identical(next, $OPEN_PAREN)) {
|
| - appendBeginGroup(OPEN_PAREN_INFO);
|
| + appendBeginGroup(TokenType.OPEN_PAREN);
|
| return advance();
|
| }
|
|
|
| if (identical(next, $SEMICOLON)) {
|
| - appendPrecedenceToken(SEMICOLON_INFO);
|
| + appendPrecedenceToken(TokenType.SEMICOLON);
|
| // Type parameters and arguments cannot contain semicolon.
|
| discardOpenLt();
|
| return advance();
|
| @@ -293,7 +291,7 @@ abstract class AbstractScanner implements Scanner {
|
| }
|
|
|
| if (identical(next, $COMMA)) {
|
| - appendPrecedenceToken(COMMA_INFO);
|
| + appendPrecedenceToken(TokenType.COMMA);
|
| return advance();
|
| }
|
|
|
| @@ -302,7 +300,8 @@ abstract class AbstractScanner implements Scanner {
|
| }
|
|
|
| if (identical(next, $CLOSE_CURLY_BRACKET)) {
|
| - return appendEndGroup(CLOSE_CURLY_BRACKET_INFO, OPEN_CURLY_BRACKET_TOKEN);
|
| + return appendEndGroup(
|
| + TokenType.CLOSE_CURLY_BRACKET, OPEN_CURLY_BRACKET_TOKEN);
|
| }
|
|
|
| if (identical(next, $SLASH)) {
|
| @@ -310,7 +309,7 @@ abstract class AbstractScanner implements Scanner {
|
| }
|
|
|
| if (identical(next, $OPEN_CURLY_BRACKET)) {
|
| - appendBeginGroup(OPEN_CURLY_BRACKET_INFO);
|
| + appendBeginGroup(TokenType.OPEN_CURLY_BRACKET);
|
| return advance();
|
| }
|
|
|
| @@ -323,7 +322,7 @@ abstract class AbstractScanner implements Scanner {
|
| }
|
|
|
| if (identical(next, $COLON)) {
|
| - appendPrecedenceToken(COLON_INFO);
|
| + appendPrecedenceToken(TokenType.COLON);
|
| return advance();
|
| }
|
|
|
| @@ -345,7 +344,7 @@ abstract class AbstractScanner implements Scanner {
|
|
|
| if (identical(next, $CLOSE_SQUARE_BRACKET)) {
|
| return appendEndGroup(
|
| - CLOSE_SQUARE_BRACKET_INFO, OPEN_SQUARE_BRACKET_TOKEN);
|
| + TokenType.CLOSE_SQUARE_BRACKET, OPEN_SQUARE_BRACKET_TOKEN);
|
| }
|
|
|
| if (identical(next, $AT)) {
|
| @@ -401,12 +400,12 @@ abstract class AbstractScanner implements Scanner {
|
| }
|
|
|
| if (identical(next, $BACKPING)) {
|
| - appendPrecedenceToken(BACKPING_INFO);
|
| + appendPrecedenceToken(TokenType.BACKPING);
|
| return advance();
|
| }
|
|
|
| if (identical(next, $BACKSLASH)) {
|
| - appendPrecedenceToken(BACKSLASH_INFO);
|
| + appendPrecedenceToken(TokenType.BACKSLASH);
|
| return advance();
|
| }
|
|
|
| @@ -436,11 +435,11 @@ abstract class AbstractScanner implements Scanner {
|
| !identical(next, $CR) &&
|
| !identical(next, $EOF));
|
| if (!asciiOnly) handleUnicode(start);
|
| - appendSubstringToken(SCRIPT_INFO, start, asciiOnly);
|
| + appendSubstringToken(TokenType.SCRIPT_TAG, start, asciiOnly);
|
| return next;
|
| }
|
| }
|
| - appendPrecedenceToken(HASH_INFO);
|
| + appendPrecedenceToken(TokenType.HASH);
|
| return advance();
|
| }
|
|
|
| @@ -448,9 +447,9 @@ abstract class AbstractScanner implements Scanner {
|
| // ~ ~/ ~/=
|
| next = advance();
|
| if (identical(next, $SLASH)) {
|
| - return select($EQ, TILDE_SLASH_EQ_INFO, TILDE_SLASH_INFO);
|
| + return select($EQ, TokenType.TILDE_SLASH_EQ, TokenType.TILDE_SLASH);
|
| } else {
|
| - appendPrecedenceToken(TILDE_INFO);
|
| + appendPrecedenceToken(TokenType.TILDE);
|
| return next;
|
| }
|
| }
|
| @@ -459,27 +458,28 @@ abstract class AbstractScanner implements Scanner {
|
| // [ [] []=
|
| next = advance();
|
| if (identical(next, $CLOSE_SQUARE_BRACKET)) {
|
| - return select($EQ, INDEX_EQ_INFO, INDEX_INFO);
|
| + return select($EQ, TokenType.INDEX_EQ, TokenType.INDEX);
|
| }
|
| - appendBeginGroup(OPEN_SQUARE_BRACKET_INFO);
|
| + appendBeginGroup(TokenType.OPEN_SQUARE_BRACKET);
|
| return next;
|
| }
|
|
|
| int tokenizeCaret(int next) {
|
| // ^ ^=
|
| - return select($EQ, CARET_EQ_INFO, CARET_INFO);
|
| + return select($EQ, TokenType.CARET_EQ, TokenType.CARET);
|
| }
|
|
|
| int tokenizeQuestion(int next) {
|
| // ? ?. ?? ??=
|
| next = advance();
|
| if (identical(next, $QUESTION)) {
|
| - return select($EQ, QUESTION_QUESTION_EQ_INFO, QUESTION_QUESTION_INFO);
|
| + return select(
|
| + $EQ, TokenType.QUESTION_QUESTION_EQ, TokenType.QUESTION_QUESTION);
|
| } else if (identical(next, $PERIOD)) {
|
| - appendPrecedenceToken(QUESTION_PERIOD_INFO);
|
| + appendPrecedenceToken(TokenType.QUESTION_PERIOD);
|
| return advance();
|
| } else {
|
| - appendPrecedenceToken(QUESTION_INFO);
|
| + appendPrecedenceToken(TokenType.QUESTION);
|
| return next;
|
| }
|
| }
|
| @@ -488,13 +488,13 @@ abstract class AbstractScanner implements Scanner {
|
| // | || |=
|
| next = advance();
|
| if (identical(next, $BAR)) {
|
| - appendPrecedenceToken(BAR_BAR_INFO);
|
| + appendPrecedenceToken(TokenType.BAR_BAR);
|
| return advance();
|
| } else if (identical(next, $EQ)) {
|
| - appendPrecedenceToken(BAR_EQ_INFO);
|
| + appendPrecedenceToken(TokenType.BAR_EQ);
|
| return advance();
|
| } else {
|
| - appendPrecedenceToken(BAR_INFO);
|
| + appendPrecedenceToken(TokenType.BAR);
|
| return next;
|
| }
|
| }
|
| @@ -503,38 +503,38 @@ abstract class AbstractScanner implements Scanner {
|
| // && &= &
|
| next = advance();
|
| if (identical(next, $AMPERSAND)) {
|
| - appendPrecedenceToken(AMPERSAND_AMPERSAND_INFO);
|
| + appendPrecedenceToken(TokenType.AMPERSAND_AMPERSAND);
|
| return advance();
|
| } else if (identical(next, $EQ)) {
|
| - appendPrecedenceToken(AMPERSAND_EQ_INFO);
|
| + appendPrecedenceToken(TokenType.AMPERSAND_EQ);
|
| return advance();
|
| } else {
|
| - appendPrecedenceToken(AMPERSAND_INFO);
|
| + appendPrecedenceToken(TokenType.AMPERSAND);
|
| return next;
|
| }
|
| }
|
|
|
| int tokenizePercent(int next) {
|
| // % %=
|
| - return select($EQ, PERCENT_EQ_INFO, PERCENT_INFO);
|
| + return select($EQ, TokenType.PERCENT_EQ, TokenType.PERCENT);
|
| }
|
|
|
| int tokenizeMultiply(int next) {
|
| // * *=
|
| - return select($EQ, STAR_EQ_INFO, STAR_INFO);
|
| + return select($EQ, TokenType.STAR_EQ, TokenType.STAR);
|
| }
|
|
|
| int tokenizeMinus(int next) {
|
| // - -- -=
|
| next = advance();
|
| if (identical(next, $MINUS)) {
|
| - appendPrecedenceToken(MINUS_MINUS_INFO);
|
| + appendPrecedenceToken(TokenType.MINUS_MINUS);
|
| return advance();
|
| } else if (identical(next, $EQ)) {
|
| - appendPrecedenceToken(MINUS_EQ_INFO);
|
| + appendPrecedenceToken(TokenType.MINUS_EQ);
|
| return advance();
|
| } else {
|
| - appendPrecedenceToken(MINUS_INFO);
|
| + appendPrecedenceToken(TokenType.MINUS);
|
| return next;
|
| }
|
| }
|
| @@ -543,13 +543,13 @@ abstract class AbstractScanner implements Scanner {
|
| // + ++ +=
|
| next = advance();
|
| if (identical($PLUS, next)) {
|
| - appendPrecedenceToken(PLUS_PLUS_INFO);
|
| + appendPrecedenceToken(TokenType.PLUS_PLUS);
|
| return advance();
|
| } else if (identical($EQ, next)) {
|
| - appendPrecedenceToken(PLUS_EQ_INFO);
|
| + appendPrecedenceToken(TokenType.PLUS_EQ);
|
| return advance();
|
| } else {
|
| - appendPrecedenceToken(PLUS_INFO);
|
| + appendPrecedenceToken(TokenType.PLUS);
|
| return next;
|
| }
|
| }
|
| @@ -560,9 +560,9 @@ abstract class AbstractScanner implements Scanner {
|
|
|
| next = advance();
|
| if (identical(next, $EQ)) {
|
| - return select($EQ, BANG_EQ_EQ_INFO, BANG_EQ_INFO);
|
| + return select($EQ, TokenType.BANG_EQ_EQ, TokenType.BANG_EQ);
|
| }
|
| - appendPrecedenceToken(BANG_INFO);
|
| + appendPrecedenceToken(TokenType.BANG);
|
| return next;
|
| }
|
|
|
| @@ -576,12 +576,12 @@ abstract class AbstractScanner implements Scanner {
|
|
|
| next = advance();
|
| if (identical(next, $EQ)) {
|
| - return select($EQ, EQ_EQ_EQ_INFO, EQ_EQ_INFO);
|
| + return select($EQ, TokenType.EQ_EQ_EQ, TokenType.EQ_EQ);
|
| } else if (identical(next, $GT)) {
|
| - appendPrecedenceToken(FUNCTION_INFO);
|
| + appendPrecedenceToken(TokenType.FUNCTION);
|
| return advance();
|
| }
|
| - appendPrecedenceToken(EQ_INFO);
|
| + appendPrecedenceToken(TokenType.EQ);
|
| return next;
|
| }
|
|
|
| @@ -589,19 +589,19 @@ abstract class AbstractScanner implements Scanner {
|
| // > >= >> >>=
|
| next = advance();
|
| if (identical($EQ, next)) {
|
| - appendPrecedenceToken(GT_EQ_INFO);
|
| + appendPrecedenceToken(TokenType.GT_EQ);
|
| return advance();
|
| } else if (identical($GT, next)) {
|
| next = advance();
|
| if (identical($EQ, next)) {
|
| - appendPrecedenceToken(GT_GT_EQ_INFO);
|
| + appendPrecedenceToken(TokenType.GT_GT_EQ);
|
| return advance();
|
| } else {
|
| - appendGtGt(GT_GT_INFO);
|
| + appendGtGt(TokenType.GT_GT);
|
| return next;
|
| }
|
| } else {
|
| - appendGt(GT_INFO);
|
| + appendGt(TokenType.GT);
|
| return next;
|
| }
|
| }
|
| @@ -610,12 +610,12 @@ abstract class AbstractScanner implements Scanner {
|
| // < <= << <<=
|
| next = advance();
|
| if (identical($EQ, next)) {
|
| - appendPrecedenceToken(LT_EQ_INFO);
|
| + appendPrecedenceToken(TokenType.LT_EQ);
|
| return advance();
|
| } else if (identical($LT, next)) {
|
| - return select($EQ, LT_LT_EQ_INFO, LT_LT_INFO);
|
| + return select($EQ, TokenType.LT_LT_EQ, TokenType.LT_LT);
|
| } else {
|
| - appendBeginGroup(LT_INFO);
|
| + appendBeginGroup(TokenType.LT);
|
| return next;
|
| }
|
| }
|
| @@ -635,7 +635,7 @@ abstract class AbstractScanner implements Scanner {
|
| return tokenizeFractionPart(advance(), start);
|
| }
|
| }
|
| - appendSubstringToken(INT_INFO, start, true);
|
| + appendSubstringToken(TokenType.INT, start, true);
|
| return next;
|
| }
|
| }
|
| @@ -664,7 +664,7 @@ abstract class AbstractScanner implements Scanner {
|
| unterminated('0x', shouldAdvance: false);
|
| return next;
|
| }
|
| - appendSubstringToken(HEXADECIMAL_INFO, start, true);
|
| + appendSubstringToken(TokenType.HEXADECIMAL, start, true);
|
| return next;
|
| }
|
| }
|
| @@ -676,9 +676,10 @@ abstract class AbstractScanner implements Scanner {
|
| if (($0 <= next && next <= $9)) {
|
| return tokenizeFractionPart(next, start);
|
| } else if (identical($PERIOD, next)) {
|
| - return select($PERIOD, PERIOD_PERIOD_PERIOD_INFO, PERIOD_PERIOD_INFO);
|
| + return select(
|
| + $PERIOD, TokenType.PERIOD_PERIOD_PERIOD, TokenType.PERIOD_PERIOD);
|
| } else {
|
| - appendPrecedenceToken(PERIOD_INFO);
|
| + appendPrecedenceToken(TokenType.PERIOD);
|
| return next;
|
| }
|
| }
|
| @@ -720,17 +721,18 @@ abstract class AbstractScanner implements Scanner {
|
| }
|
| if (!hasDigit) {
|
| // Reduce offset, we already advanced to the token past the period.
|
| - appendSubstringToken(INT_INFO, start, true, -1);
|
| + appendSubstringToken(TokenType.INT, start, true, -1);
|
|
|
| // TODO(ahe): Wrong offset for the period. Cannot call beginToken because
|
| // the scanner already advanced past the period.
|
| if (identical($PERIOD, next)) {
|
| - return select($PERIOD, PERIOD_PERIOD_PERIOD_INFO, PERIOD_PERIOD_INFO);
|
| + return select(
|
| + $PERIOD, TokenType.PERIOD_PERIOD_PERIOD, TokenType.PERIOD_PERIOD);
|
| }
|
| - appendPrecedenceToken(PERIOD_INFO);
|
| + appendPrecedenceToken(TokenType.PERIOD);
|
| return next;
|
| }
|
| - appendSubstringToken(DOUBLE_INFO, start, true);
|
| + appendSubstringToken(TokenType.DOUBLE, start, true);
|
| return next;
|
| }
|
|
|
| @@ -742,10 +744,10 @@ abstract class AbstractScanner implements Scanner {
|
| } else if (identical($SLASH, next)) {
|
| return tokenizeSingleLineComment(next, start);
|
| } else if (identical($EQ, next)) {
|
| - appendPrecedenceToken(SLASH_EQ_INFO);
|
| + appendPrecedenceToken(TokenType.SLASH_EQ);
|
| return advance();
|
| } else {
|
| - appendPrecedenceToken(SLASH_INFO);
|
| + appendPrecedenceToken(TokenType.SLASH);
|
| return next;
|
| }
|
| }
|
| @@ -761,9 +763,9 @@ abstract class AbstractScanner implements Scanner {
|
| identical($EOF, next)) {
|
| if (!asciiOnly) handleUnicode(start);
|
| if (dartdoc) {
|
| - appendDartDoc(start, SINGLE_LINE_COMMENT_INFO, asciiOnly);
|
| + appendDartDoc(start, TokenType.SINGLE_LINE_COMMENT, asciiOnly);
|
| } else {
|
| - appendComment(start, SINGLE_LINE_COMMENT_INFO, asciiOnly);
|
| + appendComment(start, TokenType.SINGLE_LINE_COMMENT, asciiOnly);
|
| }
|
| return next;
|
| }
|
| @@ -790,9 +792,11 @@ abstract class AbstractScanner implements Scanner {
|
| if (!asciiOnlyLines) handleUnicode(unicodeStart);
|
| next = advance();
|
| if (dartdoc) {
|
| - appendDartDoc(start, MULTI_LINE_COMMENT_INFO, asciiOnlyComment);
|
| + appendDartDoc(
|
| + start, TokenType.MULTI_LINE_COMMENT, asciiOnlyComment);
|
| } else {
|
| - appendComment(start, MULTI_LINE_COMMENT_INFO, asciiOnlyComment);
|
| + appendComment(
|
| + start, TokenType.MULTI_LINE_COMMENT, asciiOnlyComment);
|
| }
|
| break;
|
| } else {
|
| @@ -836,7 +840,7 @@ abstract class AbstractScanner implements Scanner {
|
| value.codeUnitAt(1) == $STAR &&
|
| value.codeUnitAt(2) == $EQ) {
|
| newComment = new CommentToken.fromString(
|
| - GENERIC_METHOD_TYPE_ASSIGN, value, start);
|
| + TokenType.GENERIC_METHOD_TYPE_ASSIGN, value, start);
|
| } else if (length > 6 &&
|
| value.codeUnitAt(0) == $SLASH &&
|
| value.codeUnitAt(1) == $STAR &&
|
| @@ -844,8 +848,8 @@ abstract class AbstractScanner implements Scanner {
|
| value.codeUnitAt(length - 1) == $SLASH &&
|
| value.codeUnitAt(length - 2) == $STAR &&
|
| value.codeUnitAt(length - 3) == $GT) {
|
| - newComment =
|
| - new CommentToken.fromString(GENERIC_METHOD_TYPE_LIST, value, start);
|
| + newComment = new CommentToken.fromString(
|
| + TokenType.GENERIC_METHOD_TYPE_LIST, value, start);
|
| }
|
| }
|
| _appendToCommentStream(newComment);
|
| @@ -944,7 +948,7 @@ abstract class AbstractScanner implements Scanner {
|
| if (start == scanOffset) {
|
| return unexpected(next);
|
| } else {
|
| - appendSubstringToken(IDENTIFIER_INFO, start, true);
|
| + appendSubstringToken(TokenType.IDENTIFIER, start, true);
|
| }
|
| break;
|
| }
|
| @@ -953,7 +957,7 @@ abstract class AbstractScanner implements Scanner {
|
| }
|
|
|
| int tokenizeAt(int next) {
|
| - appendPrecedenceToken(AT_INFO);
|
| + appendPrecedenceToken(TokenType.AT);
|
| return advance();
|
| }
|
|
|
| @@ -967,7 +971,7 @@ abstract class AbstractScanner implements Scanner {
|
| return tokenizeMultiLineString(quoteChar, start, raw);
|
| } else {
|
| // Empty string.
|
| - appendSubstringToken(STRING_INFO, start, true);
|
| + appendSubstringToken(TokenType.STRING, start, true);
|
| return next;
|
| }
|
| }
|
| @@ -1015,12 +1019,12 @@ abstract class AbstractScanner implements Scanner {
|
| if (!asciiOnly) handleUnicode(start);
|
| // Advance past the quote character.
|
| next = advance();
|
| - appendSubstringToken(STRING_INFO, start, asciiOnly);
|
| + appendSubstringToken(TokenType.STRING, start, asciiOnly);
|
| return next;
|
| }
|
|
|
| int tokenizeStringInterpolation(int start, bool asciiOnly) {
|
| - appendSubstringToken(STRING_INFO, start, asciiOnly);
|
| + appendSubstringToken(TokenType.STRING, start, asciiOnly);
|
| beginToken(); // $ starts here.
|
| int next = advance();
|
| if (identical(next, $OPEN_CURLY_BRACKET)) {
|
| @@ -1031,7 +1035,7 @@ abstract class AbstractScanner implements Scanner {
|
| }
|
|
|
| int tokenizeInterpolatedExpression(int next) {
|
| - appendBeginGroup(STRING_INTERPOLATION_INFO);
|
| + appendBeginGroup(TokenType.STRING_INTERPOLATION_EXPRESSION);
|
| beginToken(); // The expression starts here.
|
| next = advance(); // Move past the curly bracket.
|
| while (!identical(next, $EOF) && !identical(next, $STX)) {
|
| @@ -1044,7 +1048,7 @@ abstract class AbstractScanner implements Scanner {
|
| }
|
|
|
| int tokenizeInterpolatedIdentifier(int next) {
|
| - appendPrecedenceToken(STRING_INTERPOLATION_IDENTIFIER_INFO);
|
| + appendPrecedenceToken(TokenType.STRING_INTERPOLATION_IDENTIFIER);
|
|
|
| if ($a <= next && next <= $z ||
|
| $A <= next && next <= $Z ||
|
| @@ -1064,7 +1068,7 @@ abstract class AbstractScanner implements Scanner {
|
| if (identical(next, quoteChar)) {
|
| if (!asciiOnly) handleUnicode(start);
|
| next = advance();
|
| - appendSubstringToken(STRING_INFO, start, asciiOnly);
|
| + appendSubstringToken(TokenType.STRING, start, asciiOnly);
|
| return next;
|
| } else if (identical(next, $LF) || identical(next, $CR)) {
|
| if (!asciiOnly) handleUnicode(start);
|
| @@ -1107,7 +1111,7 @@ abstract class AbstractScanner implements Scanner {
|
| if (identical(next, quoteChar)) {
|
| if (!asciiOnlyLine) handleUnicode(unicodeStart);
|
| next = advance();
|
| - appendSubstringToken(STRING_INFO, start, asciiOnlyString);
|
| + appendSubstringToken(TokenType.STRING, start, asciiOnlyString);
|
| return next;
|
| }
|
| }
|
| @@ -1139,7 +1143,7 @@ abstract class AbstractScanner implements Scanner {
|
| if (identical(next, quoteChar)) {
|
| if (!asciiOnlyLine) handleUnicode(unicodeStart);
|
| next = advance();
|
| - appendSubstringToken(STRING_INFO, start, asciiOnlyString);
|
| + appendSubstringToken(TokenType.STRING, start, asciiOnlyString);
|
| return next;
|
| }
|
| }
|
| @@ -1207,11 +1211,11 @@ abstract class AbstractScanner implements Scanner {
|
|
|
| TokenType closeBraceInfoFor(BeginGroupToken begin) {
|
| return const {
|
| - '(': CLOSE_PAREN_INFO,
|
| - '[': CLOSE_SQUARE_BRACKET_INFO,
|
| - '{': CLOSE_CURLY_BRACKET_INFO,
|
| - '<': GT_INFO,
|
| - r'${': CLOSE_CURLY_BRACKET_INFO,
|
| + '(': TokenType.CLOSE_PAREN,
|
| + '[': TokenType.CLOSE_SQUARE_BRACKET,
|
| + '{': TokenType.CLOSE_CURLY_BRACKET,
|
| + '<': TokenType.GT,
|
| + r'${': TokenType.CLOSE_CURLY_BRACKET,
|
| }[begin.lexeme];
|
| }
|
|
|
|
|