| 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 fasta.parser.parser; | 5 library fasta.parser.parser; |
| 6 | 6 |
| 7 import '../scanner.dart' show | 7 import '../scanner.dart' show |
| 8 ErrorToken; | 8 ErrorToken; |
| 9 | 9 |
| 10 import '../scanner/recover.dart' show | 10 import '../scanner/recover.dart' show |
| (...skipping 694 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 705 return token; | 705 return token; |
| 706 } | 706 } |
| 707 | 707 |
| 708 Token parseClassOrNamedMixinApplication(Token token) { | 708 Token parseClassOrNamedMixinApplication(Token token) { |
| 709 Token begin = token; | 709 Token begin = token; |
| 710 Token abstractKeyword; | 710 Token abstractKeyword; |
| 711 if (optional('abstract', token)) { | 711 if (optional('abstract', token)) { |
| 712 abstractKeyword = token; | 712 abstractKeyword = token; |
| 713 token = token.next; | 713 token = token.next; |
| 714 } | 714 } |
| 715 Token classKeyword = token; | |
| 716 var isMixinApplication = optional('=', peekAfterType(token.next)); | |
| 717 if (isMixinApplication) { | |
| 718 listener.beginNamedMixinApplication(begin); | |
| 719 } else { | |
| 720 listener.beginClassDeclaration(begin); | |
| 721 } | |
| 722 | |
| 723 int modifierCount = 0; | 715 int modifierCount = 0; |
| 724 if (abstractKeyword != null) { | 716 if (abstractKeyword != null) { |
| 725 parseModifier(abstractKeyword); | 717 parseModifier(abstractKeyword); |
| 726 modifierCount++; | 718 modifierCount++; |
| 727 } | 719 } |
| 728 listener.handleModifiers(modifierCount); | 720 listener.handleModifiers(modifierCount); |
| 721 bool isMixinApplication = optional('=', peekAfterType(token)); |
| 722 Token name = token.next; |
| 723 token = parseIdentifier(name); |
| 729 | 724 |
| 730 if (isMixinApplication) { | 725 if (isMixinApplication) { |
| 731 token = parseIdentifier(token.next); | 726 listener.beginNamedMixinApplication(begin, name); |
| 732 token = parseTypeVariablesOpt(token); | 727 } else { |
| 728 listener.beginClassDeclaration(begin, name); |
| 729 } |
| 730 |
| 731 token = parseTypeVariablesOpt(token); |
| 732 |
| 733 if (optional('=', token)) { |
| 733 token = expect('=', token); | 734 token = expect('=', token); |
| 734 return parseNamedMixinApplication(token, classKeyword); | 735 return parseNamedMixinApplication(token, begin, name); |
| 735 } else { | 736 } else { |
| 736 return parseClass(begin, classKeyword); | 737 return parseClass(token, begin, name); |
| 737 } | 738 } |
| 738 } | 739 } |
| 739 | 740 |
| 740 Token parseNamedMixinApplication(Token token, Token classKeyword) { | 741 Token parseNamedMixinApplication(Token token, Token begin, Token name) { |
| 741 token = parseMixinApplication(token); | 742 token = parseMixinApplication(token); |
| 742 Token implementsKeyword = null; | 743 Token implementsKeyword = null; |
| 743 if (optional('implements', token)) { | 744 if (optional('implements', token)) { |
| 744 implementsKeyword = token; | 745 implementsKeyword = token; |
| 745 token = parseTypeList(token.next); | 746 token = parseTypeList(token.next); |
| 746 } | 747 } |
| 747 listener.endNamedMixinApplication(classKeyword, implementsKeyword, token); | 748 listener.endNamedMixinApplication(begin, implementsKeyword, token); |
| 748 return expect(';', token); | 749 return expect(';', token); |
| 749 } | 750 } |
| 750 | 751 |
| 751 Token parseClass(Token begin, Token classKeyword) { | 752 Token parseClass(Token token, Token begin, Token name) { |
| 752 Token token = parseIdentifier(classKeyword.next); | |
| 753 token = parseTypeVariablesOpt(token); | |
| 754 Token extendsKeyword; | 753 Token extendsKeyword; |
| 755 if (optional('extends', token)) { | 754 if (optional('extends', token)) { |
| 756 extendsKeyword = token; | 755 extendsKeyword = token; |
| 757 if (optional('with', peekAfterType(token.next))) { | 756 if (optional('with', peekAfterType(token.next))) { |
| 758 token = parseMixinApplication(token.next); | 757 token = parseMixinApplication(token.next); |
| 759 } else { | 758 } else { |
| 760 token = parseType(token.next); | 759 token = parseType(token.next); |
| 761 } | 760 } |
| 762 } else { | 761 } else { |
| 763 extendsKeyword = null; | 762 extendsKeyword = null; |
| (...skipping 2550 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3314 break; | 3313 break; |
| 3315 } | 3314 } |
| 3316 if (isRecoverable) { | 3315 if (isRecoverable) { |
| 3317 listener.handleRecoverableError(token, kind, arguments); | 3316 listener.handleRecoverableError(token, kind, arguments); |
| 3318 return null; | 3317 return null; |
| 3319 } else { | 3318 } else { |
| 3320 return listener.handleUnrecoverableError(token, kind, arguments); | 3319 return listener.handleUnrecoverableError(token, kind, arguments); |
| 3321 } | 3320 } |
| 3322 } | 3321 } |
| 3323 } | 3322 } |
| OLD | NEW |