OLD | NEW |
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 dart_parser.top_level_parser; | 5 library dart_parser.top_level_parser; |
6 | 6 |
7 import 'package:dart_scanner/src/token.dart' show | 7 import 'package:dart_scanner/src/token.dart' show |
8 BeginGroupToken, | |
9 Token; | 8 Token; |
10 | 9 |
11 import 'package:dart_scanner/src/characters.dart' show | |
12 $CLOSE_CURLY_BRACKET; | |
13 | |
14 import 'listener.dart' show | 10 import 'listener.dart' show |
15 Listener; | 11 Listener; |
16 | 12 |
17 import 'class_member_parser.dart' show | 13 import 'class_member_parser.dart' show |
18 ClassMemberParser; | 14 ClassMemberParser; |
19 | 15 |
20 import 'parser.dart' show | |
21 optional; | |
22 | |
23 /// Parser which only parses top-level elements, but ignores their bodies. | 16 /// Parser which only parses top-level elements, but ignores their bodies. |
24 /// Use [Parser] to parse everything. | 17 /// Use [Parser] to parse everything. |
25 class TopLevelParser extends ClassMemberParser { | 18 class TopLevelParser extends ClassMemberParser { |
26 TopLevelParser(Listener listener, | 19 TopLevelParser(Listener listener, |
27 {bool asyncAwaitKeywordsEnabled: false, | 20 {bool asyncAwaitKeywordsEnabled: false, |
28 bool enableGenericMethodSyntax: false}) | 21 bool enableGenericMethodSyntax: false}) |
29 : super(listener, asyncAwaitKeywordsEnabled: asyncAwaitKeywordsEnabled, | 22 : super(listener, asyncAwaitKeywordsEnabled: asyncAwaitKeywordsEnabled, |
30 enableGenericMethodSyntax: enableGenericMethodSyntax); | 23 enableGenericMethodSyntax: enableGenericMethodSyntax); |
31 | 24 |
32 Token parseClassBody(Token token) { | 25 Token parseClassBody(Token token) => skipClassBody(token); |
33 if (!optional('{', token)) { | |
34 return listener.expectedClassBodyToSkip(token); | |
35 } | |
36 BeginGroupToken beginGroupToken = token; | |
37 Token endGroup = beginGroupToken.endGroup; | |
38 if (endGroup == null) { | |
39 return listener.unmatched(beginGroupToken); | |
40 } else if (!identical(endGroup.kind, $CLOSE_CURLY_BRACKET)) { | |
41 return listener.unmatched(beginGroupToken); | |
42 } | |
43 return endGroup; | |
44 } | |
45 } | 26 } |
OLD | NEW |