| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 library dart2js.parser; | 5 library dart2js.parser; |
| 6 | 6 |
| 7 import '../common.dart'; | 7 import '../common.dart'; |
| 8 import '../tokens/keyword.dart' show Keyword; | 8 import '../tokens/keyword.dart' show Keyword; |
| 9 import '../tokens/precedence.dart' show PrecedenceInfo; | 9 import '../tokens/precedence.dart' show PrecedenceInfo; |
| 10 import '../tokens/precedence_constants.dart' | 10 import '../tokens/precedence_constants.dart' |
| (...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 355 period = token; | 355 period = token; |
| 356 token = parseIdentifier(token.next); | 356 token = parseIdentifier(token.next); |
| 357 } | 357 } |
| 358 token = parseArgumentsOpt(token); | 358 token = parseArgumentsOpt(token); |
| 359 listener.endMetadata(atToken, period, token); | 359 listener.endMetadata(atToken, period, token); |
| 360 return token; | 360 return token; |
| 361 } | 361 } |
| 362 | 362 |
| 363 Token parseTypedef(Token token) { | 363 Token parseTypedef(Token token) { |
| 364 Token typedefKeyword = token; | 364 Token typedefKeyword = token; |
| 365 if (optional('=', peekAfterType(token.next))) { | 365 listener.beginFunctionTypeAlias(token); |
| 366 // TODO(aprelev@gmail.com): Remove deprecated 'typedef' mixin application, | 366 token = parseReturnTypeOpt(token.next); |
| 367 // remove corresponding diagnostic from members.dart. | 367 token = parseIdentifier(token); |
| 368 listener.beginNamedMixinApplication(token); | 368 token = parseTypeVariablesOpt(token); |
| 369 token = parseIdentifier(token.next); | 369 token = parseFormalParameters(token); |
| 370 token = parseTypeVariablesOpt(token); | 370 listener.endFunctionTypeAlias(typedefKeyword, token); |
| 371 token = expect('=', token); | |
| 372 token = parseModifiers(token); | |
| 373 token = parseMixinApplication(token); | |
| 374 Token implementsKeyword = null; | |
| 375 if (optional('implements', token)) { | |
| 376 implementsKeyword = token; | |
| 377 token = parseTypeList(token.next); | |
| 378 } | |
| 379 listener.endNamedMixinApplication( | |
| 380 typedefKeyword, implementsKeyword, token); | |
| 381 } else { | |
| 382 listener.beginFunctionTypeAlias(token); | |
| 383 token = parseReturnTypeOpt(token.next); | |
| 384 token = parseIdentifier(token); | |
| 385 token = parseTypeVariablesOpt(token); | |
| 386 token = parseFormalParameters(token); | |
| 387 listener.endFunctionTypeAlias(typedefKeyword, token); | |
| 388 } | |
| 389 return expect(';', token); | 371 return expect(';', token); |
| 390 } | 372 } |
| 391 | 373 |
| 392 Token parseMixinApplication(Token token) { | 374 Token parseMixinApplication(Token token) { |
| 393 listener.beginMixinApplication(token); | 375 listener.beginMixinApplication(token); |
| 394 token = parseType(token); | 376 token = parseType(token); |
| 395 token = expect('with', token); | 377 token = expect('with', token); |
| 396 token = parseTypeList(token); | 378 token = parseTypeList(token); |
| 397 listener.endMixinApplication(); | 379 listener.endMixinApplication(); |
| 398 return token; | 380 return token; |
| (...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 675 Token begin = token; | 657 Token begin = token; |
| 676 Token abstractKeyword; | 658 Token abstractKeyword; |
| 677 if (optional('abstract', token)) { | 659 if (optional('abstract', token)) { |
| 678 abstractKeyword = token; | 660 abstractKeyword = token; |
| 679 token = token.next; | 661 token = token.next; |
| 680 } | 662 } |
| 681 Token classKeyword = token; | 663 Token classKeyword = token; |
| 682 var isMixinApplication = optional('=', peekAfterType(token.next)); | 664 var isMixinApplication = optional('=', peekAfterType(token.next)); |
| 683 if (isMixinApplication) { | 665 if (isMixinApplication) { |
| 684 listener.beginNamedMixinApplication(begin); | 666 listener.beginNamedMixinApplication(begin); |
| 685 token = parseIdentifier(token.next); | |
| 686 token = parseTypeVariablesOpt(token); | |
| 687 token = expect('=', token); | |
| 688 } else { | 667 } else { |
| 689 listener.beginClassDeclaration(begin); | 668 listener.beginClassDeclaration(begin); |
| 690 } | 669 } |
| 691 | 670 |
| 692 // TODO(aprelev@gmail.com): Once 'typedef' named mixin application is | |
| 693 // removed, move modifiers for named mixin application to the bottom of | |
| 694 // listener stack. This is so stacks for class declaration and named | |
| 695 // mixin application look similar. | |
| 696 int modifierCount = 0; | 671 int modifierCount = 0; |
| 697 if (abstractKeyword != null) { | 672 if (abstractKeyword != null) { |
| 698 parseModifier(abstractKeyword); | 673 parseModifier(abstractKeyword); |
| 699 modifierCount++; | 674 modifierCount++; |
| 700 } | 675 } |
| 701 listener.handleModifiers(modifierCount); | 676 listener.handleModifiers(modifierCount); |
| 702 | 677 |
| 703 if (isMixinApplication) { | 678 if (isMixinApplication) { |
| 679 token = parseIdentifier(token.next); |
| 680 token = parseTypeVariablesOpt(token); |
| 681 token = expect('=', token); |
| 704 return parseNamedMixinApplication(token, classKeyword); | 682 return parseNamedMixinApplication(token, classKeyword); |
| 705 } else { | 683 } else { |
| 706 return parseClass(begin, classKeyword); | 684 return parseClass(begin, classKeyword); |
| 707 } | 685 } |
| 708 } | 686 } |
| 709 | 687 |
| 710 Token parseNamedMixinApplication(Token token, Token classKeyword) { | 688 Token parseNamedMixinApplication(Token token, Token classKeyword) { |
| 711 token = parseMixinApplication(token); | 689 token = parseMixinApplication(token); |
| 712 Token implementsKeyword = null; | 690 Token implementsKeyword = null; |
| 713 if (optional('implements', token)) { | 691 if (optional('implements', token)) { |
| (...skipping 2277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2991 } | 2969 } |
| 2992 listener.handleContinueStatement(hasTarget, continueKeyword, token); | 2970 listener.handleContinueStatement(hasTarget, continueKeyword, token); |
| 2993 return expectSemicolon(token); | 2971 return expectSemicolon(token); |
| 2994 } | 2972 } |
| 2995 | 2973 |
| 2996 Token parseEmptyStatement(Token token) { | 2974 Token parseEmptyStatement(Token token) { |
| 2997 listener.handleEmptyStatement(token); | 2975 listener.handleEmptyStatement(token); |
| 2998 return expectSemicolon(token); | 2976 return expectSemicolon(token); |
| 2999 } | 2977 } |
| 3000 } | 2978 } |
| OLD | NEW |