| OLD | NEW |
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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 /** | 5 /** |
| 6 * Defines the tokens that are produced by the scanner, used by the parser, and | 6 * Defines the tokens that are produced by the scanner, used by the parser, and |
| 7 * referenced from the [AST structure](ast.dart). | 7 * referenced from the [AST structure](ast.dart). |
| 8 */ | 8 */ |
| 9 import 'dart:collection'; | 9 import 'dart:collection'; |
| 10 | 10 |
| (...skipping 967 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 978 static const TokenType GT_GT = | 978 static const TokenType GT_GT = |
| 979 const TokenType._('GT_GT', TokenClass.SHIFT_OPERATOR, '>>'); | 979 const TokenType._('GT_GT', TokenClass.SHIFT_OPERATOR, '>>'); |
| 980 | 980 |
| 981 static const TokenType GT_GT_EQ = | 981 static const TokenType GT_GT_EQ = |
| 982 const TokenType._('GT_GT_EQ', TokenClass.ASSIGNMENT_OPERATOR, '>>='); | 982 const TokenType._('GT_GT_EQ', TokenClass.ASSIGNMENT_OPERATOR, '>>='); |
| 983 | 983 |
| 984 static const TokenType HASH = | 984 static const TokenType HASH = |
| 985 const TokenType._('HASH', TokenClass.NO_CLASS, '#'); | 985 const TokenType._('HASH', TokenClass.NO_CLASS, '#'); |
| 986 | 986 |
| 987 static const TokenType INDEX = | 987 static const TokenType INDEX = |
| 988 const TokenType._('INDEX', TokenClass.UNARY_POSTFIX_OPERATOR, '[]'); | 988 const TokenType._('INDEX', TokenClass.NO_CLASS, '[]'); |
| 989 | 989 |
| 990 static const TokenType INDEX_EQ = | 990 static const TokenType INDEX_EQ = |
| 991 const TokenType._('INDEX_EQ', TokenClass.UNARY_POSTFIX_OPERATOR, '[]='); | 991 const TokenType._('INDEX_EQ', TokenClass.NO_CLASS, '[]='); |
| 992 | 992 |
| 993 static const TokenType LT = | 993 static const TokenType LT = |
| 994 const TokenType._('LT', TokenClass.RELATIONAL_OPERATOR, '<'); | 994 const TokenType._('LT', TokenClass.RELATIONAL_OPERATOR, '<'); |
| 995 | 995 |
| 996 static const TokenType LT_EQ = | 996 static const TokenType LT_EQ = |
| 997 const TokenType._('LT_EQ', TokenClass.RELATIONAL_OPERATOR, '<='); | 997 const TokenType._('LT_EQ', TokenClass.RELATIONAL_OPERATOR, '<='); |
| 998 | 998 |
| 999 static const TokenType LT_LT = | 999 static const TokenType LT_LT = |
| 1000 const TokenType._('LT_LT', TokenClass.SHIFT_OPERATOR, '<<'); | 1000 const TokenType._('LT_LT', TokenClass.SHIFT_OPERATOR, '<<'); |
| 1001 | 1001 |
| 1002 static const TokenType LT_LT_EQ = | 1002 static const TokenType LT_LT_EQ = |
| 1003 const TokenType._('LT_LT_EQ', TokenClass.ASSIGNMENT_OPERATOR, '<<='); | 1003 const TokenType._('LT_LT_EQ', TokenClass.ASSIGNMENT_OPERATOR, '<<='); |
| 1004 | 1004 |
| 1005 static const TokenType MINUS = | 1005 static const TokenType MINUS = |
| 1006 const TokenType._('MINUS', TokenClass.ADDITIVE_OPERATOR, '-'); | 1006 const TokenType._('MINUS', TokenClass.ADDITIVE_OPERATOR, '-'); |
| 1007 | 1007 |
| 1008 static const TokenType MINUS_EQ = | 1008 static const TokenType MINUS_EQ = |
| 1009 const TokenType._('MINUS_EQ', TokenClass.ASSIGNMENT_OPERATOR, '-='); | 1009 const TokenType._('MINUS_EQ', TokenClass.ASSIGNMENT_OPERATOR, '-='); |
| 1010 | 1010 |
| 1011 static const TokenType MINUS_MINUS = | 1011 static const TokenType MINUS_MINUS = |
| 1012 const TokenType._('MINUS_MINUS', TokenClass.UNARY_PREFIX_OPERATOR, '--'); | 1012 const TokenType._('MINUS_MINUS', TokenClass.UNARY_POSTFIX_OPERATOR, '--'); |
| 1013 | 1013 |
| 1014 static const TokenType OPEN_CURLY_BRACKET = | 1014 static const TokenType OPEN_CURLY_BRACKET = |
| 1015 const TokenType._('OPEN_CURLY_BRACKET', TokenClass.NO_CLASS, '{'); | 1015 const TokenType._('OPEN_CURLY_BRACKET', TokenClass.NO_CLASS, '{'); |
| 1016 | 1016 |
| 1017 static const TokenType OPEN_PAREN = | 1017 static const TokenType OPEN_PAREN = |
| 1018 const TokenType._('OPEN_PAREN', TokenClass.UNARY_POSTFIX_OPERATOR, '('); | 1018 const TokenType._('OPEN_PAREN', TokenClass.UNARY_POSTFIX_OPERATOR, '('); |
| 1019 | 1019 |
| 1020 static const TokenType OPEN_SQUARE_BRACKET = const TokenType._( | 1020 static const TokenType OPEN_SQUARE_BRACKET = const TokenType._( |
| 1021 'OPEN_SQUARE_BRACKET', TokenClass.UNARY_POSTFIX_OPERATOR, '['); | 1021 'OPEN_SQUARE_BRACKET', TokenClass.UNARY_POSTFIX_OPERATOR, '['); |
| 1022 | 1022 |
| 1023 static const TokenType PERCENT = | 1023 static const TokenType PERCENT = |
| 1024 const TokenType._('PERCENT', TokenClass.MULTIPLICATIVE_OPERATOR, '%'); | 1024 const TokenType._('PERCENT', TokenClass.MULTIPLICATIVE_OPERATOR, '%'); |
| 1025 | 1025 |
| 1026 static const TokenType PERCENT_EQ = | 1026 static const TokenType PERCENT_EQ = |
| 1027 const TokenType._('PERCENT_EQ', TokenClass.ASSIGNMENT_OPERATOR, '%='); | 1027 const TokenType._('PERCENT_EQ', TokenClass.ASSIGNMENT_OPERATOR, '%='); |
| 1028 | 1028 |
| 1029 static const TokenType PERIOD = | 1029 static const TokenType PERIOD = |
| 1030 const TokenType._('PERIOD', TokenClass.UNARY_POSTFIX_OPERATOR, '.'); | 1030 const TokenType._('PERIOD', TokenClass.UNARY_POSTFIX_OPERATOR, '.'); |
| 1031 | 1031 |
| 1032 static const TokenType PERIOD_PERIOD = | 1032 static const TokenType PERIOD_PERIOD = |
| 1033 const TokenType._('PERIOD_PERIOD', TokenClass.CASCADE_OPERATOR, '..'); | 1033 const TokenType._('PERIOD_PERIOD', TokenClass.CASCADE_OPERATOR, '..'); |
| 1034 | 1034 |
| 1035 static const TokenType PLUS = | 1035 static const TokenType PLUS = |
| 1036 const TokenType._('PLUS', TokenClass.ADDITIVE_OPERATOR, '+'); | 1036 const TokenType._('PLUS', TokenClass.ADDITIVE_OPERATOR, '+'); |
| 1037 | 1037 |
| 1038 static const TokenType PLUS_EQ = | 1038 static const TokenType PLUS_EQ = |
| 1039 const TokenType._('PLUS_EQ', TokenClass.ASSIGNMENT_OPERATOR, '+='); | 1039 const TokenType._('PLUS_EQ', TokenClass.ASSIGNMENT_OPERATOR, '+='); |
| 1040 | 1040 |
| 1041 static const TokenType PLUS_PLUS = | 1041 static const TokenType PLUS_PLUS = |
| 1042 const TokenType._('PLUS_PLUS', TokenClass.UNARY_PREFIX_OPERATOR, '++'); | 1042 const TokenType._('PLUS_PLUS', TokenClass.UNARY_POSTFIX_OPERATOR, '++'); |
| 1043 | 1043 |
| 1044 static const TokenType QUESTION = | 1044 static const TokenType QUESTION = |
| 1045 const TokenType._('QUESTION', TokenClass.CONDITIONAL_OPERATOR, '?'); | 1045 const TokenType._('QUESTION', TokenClass.CONDITIONAL_OPERATOR, '?'); |
| 1046 | 1046 |
| 1047 static const TokenType QUESTION_PERIOD = const TokenType._( | 1047 static const TokenType QUESTION_PERIOD = const TokenType._( |
| 1048 'QUESTION_PERIOD', TokenClass.UNARY_POSTFIX_OPERATOR, '?.'); | 1048 'QUESTION_PERIOD', TokenClass.UNARY_POSTFIX_OPERATOR, '?.'); |
| 1049 | 1049 |
| 1050 static const TokenType QUESTION_QUESTION = | 1050 static const TokenType QUESTION_QUESTION = |
| 1051 const TokenType._('QUESTION_QUESTION', TokenClass.IF_NULL_OPERATOR, '??'); | 1051 const TokenType._('QUESTION_QUESTION', TokenClass.IF_NULL_OPERATOR, '??'); |
| 1052 | 1052 |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1167 /** | 1167 /** |
| 1168 * Return `true` if this type of token represents a multiplicative operator. | 1168 * Return `true` if this type of token represents a multiplicative operator. |
| 1169 */ | 1169 */ |
| 1170 bool get isMultiplicativeOperator => | 1170 bool get isMultiplicativeOperator => |
| 1171 _tokenClass == TokenClass.MULTIPLICATIVE_OPERATOR; | 1171 _tokenClass == TokenClass.MULTIPLICATIVE_OPERATOR; |
| 1172 | 1172 |
| 1173 /** | 1173 /** |
| 1174 * Return `true` if this token type represents an operator. | 1174 * Return `true` if this token type represents an operator. |
| 1175 */ | 1175 */ |
| 1176 bool get isOperator => | 1176 bool get isOperator => |
| 1177 _tokenClass != TokenClass.NO_CLASS && | 1177 this == INDEX || |
| 1178 this != OPEN_PAREN && | 1178 this == INDEX_EQ || |
| 1179 this != OPEN_SQUARE_BRACKET && | 1179 (_tokenClass != TokenClass.NO_CLASS && |
| 1180 this != PERIOD; | 1180 this != OPEN_PAREN && |
| 1181 this != OPEN_SQUARE_BRACKET && |
| 1182 this != PERIOD); |
| 1181 | 1183 |
| 1182 /** | 1184 /** |
| 1183 * Return `true` if this type of token represents a relational operator. | 1185 * Return `true` if this type of token represents a relational operator. |
| 1184 */ | 1186 */ |
| 1185 bool get isRelationalOperator => | 1187 bool get isRelationalOperator => |
| 1186 _tokenClass == TokenClass.RELATIONAL_OPERATOR; | 1188 _tokenClass == TokenClass.RELATIONAL_OPERATOR; |
| 1187 | 1189 |
| 1188 /** | 1190 /** |
| 1189 * Return `true` if this type of token represents a shift operator. | 1191 * Return `true` if this type of token represents a shift operator. |
| 1190 */ | 1192 */ |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1275 */ | 1277 */ |
| 1276 class _EndOfFileTokenType extends TokenType { | 1278 class _EndOfFileTokenType extends TokenType { |
| 1277 /** | 1279 /** |
| 1278 * Initialize a newly created token. | 1280 * Initialize a newly created token. |
| 1279 */ | 1281 */ |
| 1280 const _EndOfFileTokenType() : super._('EOF', TokenClass.NO_CLASS, ''); | 1282 const _EndOfFileTokenType() : super._('EOF', TokenClass.NO_CLASS, ''); |
| 1281 | 1283 |
| 1282 @override | 1284 @override |
| 1283 String toString() => '-eof-'; | 1285 String toString() => '-eof-'; |
| 1284 } | 1286 } |
| OLD | NEW |