| 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 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 * | 149 * |
| 150 * Clients may not extend, implement or mix-in this class. | 150 * Clients may not extend, implement or mix-in this class. |
| 151 */ | 151 */ |
| 152 abstract class Keyword { | 152 abstract class Keyword { |
| 153 static const Keyword ABSTRACT = fasta.Keyword.ABSTRACT; | 153 static const Keyword ABSTRACT = fasta.Keyword.ABSTRACT; |
| 154 | 154 |
| 155 static const Keyword AS = fasta.Keyword.AS; | 155 static const Keyword AS = fasta.Keyword.AS; |
| 156 | 156 |
| 157 static const Keyword ASSERT = fasta.Keyword.ASSERT; | 157 static const Keyword ASSERT = fasta.Keyword.ASSERT; |
| 158 | 158 |
| 159 static const Keyword ASYNC = fasta.Keyword.ASYNC; |
| 160 |
| 161 static const Keyword AWAIT = fasta.Keyword.AWAIT; |
| 162 |
| 159 static const Keyword BREAK = fasta.Keyword.BREAK; | 163 static const Keyword BREAK = fasta.Keyword.BREAK; |
| 160 | 164 |
| 161 static const Keyword CASE = fasta.Keyword.CASE; | 165 static const Keyword CASE = fasta.Keyword.CASE; |
| 162 | 166 |
| 163 static const Keyword CATCH = fasta.Keyword.CATCH; | 167 static const Keyword CATCH = fasta.Keyword.CATCH; |
| 164 | 168 |
| 165 static const Keyword CLASS = fasta.Keyword.CLASS; | 169 static const Keyword CLASS = fasta.Keyword.CLASS; |
| 166 | 170 |
| 167 static const Keyword CONST = fasta.Keyword.CONST; | 171 static const Keyword CONST = fasta.Keyword.CONST; |
| 168 | 172 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 191 static const Keyword FACTORY = fasta.Keyword.FACTORY; | 195 static const Keyword FACTORY = fasta.Keyword.FACTORY; |
| 192 | 196 |
| 193 static const Keyword FALSE = fasta.Keyword.FALSE; | 197 static const Keyword FALSE = fasta.Keyword.FALSE; |
| 194 | 198 |
| 195 static const Keyword FINAL = fasta.Keyword.FINAL; | 199 static const Keyword FINAL = fasta.Keyword.FINAL; |
| 196 | 200 |
| 197 static const Keyword FINALLY = fasta.Keyword.FINALLY; | 201 static const Keyword FINALLY = fasta.Keyword.FINALLY; |
| 198 | 202 |
| 199 static const Keyword FOR = fasta.Keyword.FOR; | 203 static const Keyword FOR = fasta.Keyword.FOR; |
| 200 | 204 |
| 205 static const Keyword FUNCTION = fasta.Keyword.FUNCTION; |
| 206 |
| 201 static const Keyword GET = fasta.Keyword.GET; | 207 static const Keyword GET = fasta.Keyword.GET; |
| 202 | 208 |
| 209 static const Keyword HIDE = fasta.Keyword.HIDE; |
| 210 |
| 203 static const Keyword IF = fasta.Keyword.IF; | 211 static const Keyword IF = fasta.Keyword.IF; |
| 204 | 212 |
| 205 static const Keyword IMPLEMENTS = fasta.Keyword.IMPLEMENTS; | 213 static const Keyword IMPLEMENTS = fasta.Keyword.IMPLEMENTS; |
| 206 | 214 |
| 207 static const Keyword IMPORT = fasta.Keyword.IMPORT; | 215 static const Keyword IMPORT = fasta.Keyword.IMPORT; |
| 208 | 216 |
| 209 static const Keyword IN = fasta.Keyword.IN; | 217 static const Keyword IN = fasta.Keyword.IN; |
| 210 | 218 |
| 211 static const Keyword IS = fasta.Keyword.IS; | 219 static const Keyword IS = fasta.Keyword.IS; |
| 212 | 220 |
| 213 static const Keyword LIBRARY = fasta.Keyword.LIBRARY; | 221 static const Keyword LIBRARY = fasta.Keyword.LIBRARY; |
| 214 | 222 |
| 223 static const Keyword NATIVE = fasta.Keyword.NATIVE; |
| 224 |
| 215 static const Keyword NEW = fasta.Keyword.NEW; | 225 static const Keyword NEW = fasta.Keyword.NEW; |
| 216 | 226 |
| 217 static const Keyword NULL = fasta.Keyword.NULL; | 227 static const Keyword NULL = fasta.Keyword.NULL; |
| 218 | 228 |
| 229 static const Keyword OF = fasta.Keyword.OF; |
| 230 |
| 231 static const Keyword ON = fasta.Keyword.ON; |
| 232 |
| 219 static const Keyword OPERATOR = fasta.Keyword.OPERATOR; | 233 static const Keyword OPERATOR = fasta.Keyword.OPERATOR; |
| 220 | 234 |
| 221 static const Keyword PART = fasta.Keyword.PART; | 235 static const Keyword PART = fasta.Keyword.PART; |
| 222 | 236 |
| 237 static const Keyword PATCH = fasta.Keyword.PATCH; |
| 238 |
| 223 static const Keyword RETHROW = fasta.Keyword.RETHROW; | 239 static const Keyword RETHROW = fasta.Keyword.RETHROW; |
| 224 | 240 |
| 225 static const Keyword RETURN = fasta.Keyword.RETURN; | 241 static const Keyword RETURN = fasta.Keyword.RETURN; |
| 226 | 242 |
| 227 static const Keyword SET = fasta.Keyword.SET; | 243 static const Keyword SET = fasta.Keyword.SET; |
| 228 | 244 |
| 245 static const Keyword SHOW = fasta.Keyword.SHOW; |
| 246 |
| 247 static const Keyword SOURCE = fasta.Keyword.SOURCE; |
| 248 |
| 229 static const Keyword STATIC = fasta.Keyword.STATIC; | 249 static const Keyword STATIC = fasta.Keyword.STATIC; |
| 230 | 250 |
| 231 static const Keyword SUPER = fasta.Keyword.SUPER; | 251 static const Keyword SUPER = fasta.Keyword.SUPER; |
| 232 | 252 |
| 233 static const Keyword SWITCH = fasta.Keyword.SWITCH; | 253 static const Keyword SWITCH = fasta.Keyword.SWITCH; |
| 234 | 254 |
| 255 static const Keyword SYNC = fasta.Keyword.SYNC; |
| 256 |
| 235 static const Keyword THIS = fasta.Keyword.THIS; | 257 static const Keyword THIS = fasta.Keyword.THIS; |
| 236 | 258 |
| 237 static const Keyword THROW = fasta.Keyword.THROW; | 259 static const Keyword THROW = fasta.Keyword.THROW; |
| 238 | 260 |
| 239 static const Keyword TRUE = fasta.Keyword.TRUE; | 261 static const Keyword TRUE = fasta.Keyword.TRUE; |
| 240 | 262 |
| 241 static const Keyword TRY = fasta.Keyword.TRY; | 263 static const Keyword TRY = fasta.Keyword.TRY; |
| 242 | 264 |
| 243 static const Keyword TYPEDEF = fasta.Keyword.TYPEDEF; | 265 static const Keyword TYPEDEF = fasta.Keyword.TYPEDEF; |
| 244 | 266 |
| 245 static const Keyword VAR = fasta.Keyword.VAR; | 267 static const Keyword VAR = fasta.Keyword.VAR; |
| 246 | 268 |
| 247 static const Keyword VOID = fasta.Keyword.VOID; | 269 static const Keyword VOID = fasta.Keyword.VOID; |
| 248 | 270 |
| 249 static const Keyword WHILE = fasta.Keyword.WHILE; | 271 static const Keyword WHILE = fasta.Keyword.WHILE; |
| 250 | 272 |
| 251 static const Keyword WITH = fasta.Keyword.WITH; | 273 static const Keyword WITH = fasta.Keyword.WITH; |
| 252 | 274 |
| 275 static const Keyword YIELD = fasta.Keyword.YIELD; |
| 276 |
| 253 static const List<Keyword> values = const <Keyword>[ | 277 static const List<Keyword> values = const <Keyword>[ |
| 254 ABSTRACT, | 278 ABSTRACT, |
| 255 AS, | 279 AS, |
| 256 ASSERT, | 280 ASSERT, |
| 281 ASYNC, |
| 282 AWAIT, |
| 257 BREAK, | 283 BREAK, |
| 258 CASE, | 284 CASE, |
| 259 CATCH, | 285 CATCH, |
| 260 CLASS, | 286 CLASS, |
| 261 CONST, | 287 CONST, |
| 262 CONTINUE, | 288 CONTINUE, |
| 263 COVARIANT, | 289 COVARIANT, |
| 264 DEFAULT, | 290 DEFAULT, |
| 265 DEFERRED, | 291 DEFERRED, |
| 266 DO, | 292 DO, |
| 267 DYNAMIC, | 293 DYNAMIC, |
| 268 ELSE, | 294 ELSE, |
| 269 ENUM, | 295 ENUM, |
| 270 EXPORT, | 296 EXPORT, |
| 271 EXTENDS, | 297 EXTENDS, |
| 272 EXTERNAL, | 298 EXTERNAL, |
| 273 FACTORY, | 299 FACTORY, |
| 274 FALSE, | 300 FALSE, |
| 275 FINAL, | 301 FINAL, |
| 276 FINALLY, | 302 FINALLY, |
| 277 FOR, | 303 FOR, |
| 304 FUNCTION, |
| 278 GET, | 305 GET, |
| 306 HIDE, |
| 279 IF, | 307 IF, |
| 280 IMPLEMENTS, | 308 IMPLEMENTS, |
| 281 IMPORT, | 309 IMPORT, |
| 282 IN, | 310 IN, |
| 283 IS, | 311 IS, |
| 284 LIBRARY, | 312 LIBRARY, |
| 313 NATIVE, |
| 285 NEW, | 314 NEW, |
| 286 NULL, | 315 NULL, |
| 316 OF, |
| 317 ON, |
| 287 OPERATOR, | 318 OPERATOR, |
| 288 PART, | 319 PART, |
| 320 PATCH, |
| 289 RETHROW, | 321 RETHROW, |
| 290 RETURN, | 322 RETURN, |
| 291 SET, | 323 SET, |
| 324 SHOW, |
| 325 SOURCE, |
| 292 STATIC, | 326 STATIC, |
| 293 SUPER, | 327 SUPER, |
| 294 SWITCH, | 328 SWITCH, |
| 329 SYNC, |
| 295 THIS, | 330 THIS, |
| 296 THROW, | 331 THROW, |
| 297 TRUE, | 332 TRUE, |
| 298 TRY, | 333 TRY, |
| 299 TYPEDEF, | 334 TYPEDEF, |
| 300 VAR, | 335 VAR, |
| 301 VOID, | 336 VOID, |
| 302 WHILE, | 337 WHILE, |
| 303 WITH, | 338 WITH, |
| 339 YIELD, |
| 304 ]; | 340 ]; |
| 305 | 341 |
| 306 /** | 342 /** |
| 307 * A table mapping the lexemes of keywords to the corresponding keyword. | 343 * A table mapping the lexemes of keywords to the corresponding keyword. |
| 308 */ | 344 */ |
| 309 static final Map<String, Keyword> keywords = _createKeywordMap(); | 345 static final Map<String, Keyword> keywords = _createKeywordMap(); |
| 310 | 346 |
| 311 final fasta.PrecedenceInfo info; | 347 final fasta.PrecedenceInfo info; |
| 312 | 348 |
| 313 /** | 349 /** |
| (...skipping 13 matching lines...) Expand all Loading... |
| 327 final String syntax; | 363 final String syntax; |
| 328 | 364 |
| 329 /** | 365 /** |
| 330 * Initialize a newly created keyword. | 366 * Initialize a newly created keyword. |
| 331 */ | 367 */ |
| 332 const Keyword(this.syntax, | 368 const Keyword(this.syntax, |
| 333 {this.isBuiltIn: false, | 369 {this.isBuiltIn: false, |
| 334 this.isPseudo: false, | 370 this.isPseudo: false, |
| 335 this.info: fasta.KEYWORD_INFO}); | 371 this.info: fasta.KEYWORD_INFO}); |
| 336 | 372 |
| 373 bool get isBuiltInOrPseudo => isBuiltIn || isPseudo; |
| 374 |
| 337 /** | 375 /** |
| 338 * A flag indicating whether the keyword is "built-in" identifier. | 376 * A flag indicating whether the keyword is "built-in" identifier. |
| 339 * This method exists for backward compatibility and will be removed. | 377 * This method exists for backward compatibility and will be removed. |
| 340 * Use [isBuiltIn] instead. | 378 * Use [isBuiltIn] instead. |
| 341 */ | 379 */ |
| 342 @deprecated | 380 @deprecated |
| 343 bool get isPseudoKeyword => isBuiltIn; // TODO (danrubel): remove this | 381 bool get isPseudoKeyword => isBuiltIn; // TODO (danrubel): remove this |
| 344 | 382 |
| 345 /** | 383 /** |
| 346 * The name of the keyword type. | 384 * The name of the keyword type. |
| (...skipping 869 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1216 | 1254 |
| 1217 void set precedingComments(CommentToken comment) { | 1255 void set precedingComments(CommentToken comment) { |
| 1218 _precedingComment = comment; | 1256 _precedingComment = comment; |
| 1219 _setCommentParent(_precedingComment); | 1257 _setCommentParent(_precedingComment); |
| 1220 } | 1258 } |
| 1221 | 1259 |
| 1222 @override | 1260 @override |
| 1223 Token copy() => | 1261 Token copy() => |
| 1224 new TokenWithComment(type, offset, copyComments(precedingComments)); | 1262 new TokenWithComment(type, offset, copyComments(precedingComments)); |
| 1225 } | 1263 } |
| OLD | NEW |