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 library fasta.diet_parser; | 5 library fasta.diet_parser; |
6 | 6 |
7 import 'package:dart_scanner/src/token.dart' show | 7 import 'package:dart_scanner/src/token.dart' show |
8 BeginGroupToken, | 8 BeginGroupToken, |
9 Token; | 9 Token; |
10 | 10 |
11 import 'package:dart_parser/src/class_member_parser.dart' show | 11 import 'package:dart_parser/src/class_member_parser.dart' show |
12 ClassMemberParser; | 12 ClassMemberParser; |
13 | 13 |
14 import 'package:dart_parser/src/error_kind.dart' show | 14 import 'package:dart_parser/src/error_kind.dart' show |
15 ErrorKind; | 15 ErrorKind; |
16 | 16 |
17 import 'package:dart_parser/src/listener.dart' show | 17 import 'package:dart_parser/src/listener.dart' show |
18 Listener; | 18 Listener; |
19 | 19 |
20 import 'package:dart_parser/src/parser.dart' show | 20 import 'package:dart_parser/src/parser.dart' show |
21 optional; | 21 optional; |
22 | 22 |
23 // TODO(ahe): Move this to parser package. | 23 // TODO(ahe): Move this to parser package. |
24 class DietParser extends ClassMemberParser { | 24 class DietParser extends ClassMemberParser { |
25 DietParser(Listener listener, | 25 DietParser(Listener listener, {bool asyncAwaitKeywordsEnabled: false}) |
26 {bool asyncAwaitKeywordsEnabled: false, | 26 : super(listener, asyncAwaitKeywordsEnabled: asyncAwaitKeywordsEnabled); |
27 bool enableGenericMethodSyntax: false}) | |
28 : super(listener, asyncAwaitKeywordsEnabled: asyncAwaitKeywordsEnabled, | |
29 enableGenericMethodSyntax: enableGenericMethodSyntax); | |
30 | 27 |
31 Token parseFormalParameters(Token token) => skipFormals(token); | 28 Token parseFormalParameters(Token token) => skipFormals(token); |
32 | 29 |
33 Token skipFormals(Token token) { | 30 Token skipFormals(Token token) { |
34 listener.beginOptionalFormalParameters(token); | 31 listener.beginOptionalFormalParameters(token); |
35 if (!optional('(', token)) { | 32 if (!optional('(', token)) { |
36 if (optional(';', token)) { | 33 if (optional(';', token)) { |
37 listener.reportError(token, ErrorKind.EXPECTED_OPEN_PARENS); | 34 listener.reportError(token, ErrorKind.EXPECTED_OPEN_PARENS); |
38 return token; | 35 return token; |
39 } | 36 } |
40 return listener.unexpected(token); | 37 return listener.unexpected(token); |
41 } | 38 } |
42 BeginGroupToken beginGroupToken = token; | 39 BeginGroupToken beginGroupToken = token; |
43 Token endToken = beginGroupToken.endGroup; | 40 Token endToken = beginGroupToken.endGroup; |
44 listener.endFormalParameters(0, token, endToken); | 41 listener.endFormalParameters(0, token, endToken); |
45 return endToken.next; | 42 return endToken.next; |
46 } | 43 } |
47 } | 44 } |
OLD | NEW |