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 '../fasta_codes.dart' show codeExpectedOpenParens; | 7 import '../fasta_codes.dart' show codeExpectedOpenParens; |
8 | 8 |
9 import '../parser/class_member_parser.dart' show ClassMemberParser; | 9 import '../parser/class_member_parser.dart' show ClassMemberParser; |
10 | 10 |
11 import '../parser/listener.dart' show Listener; | 11 import '../parser/listener.dart' show Listener; |
12 | 12 |
13 import '../parser/parser.dart' show optional; | 13 import '../parser/parser.dart' show MemberKind, optional; |
14 | 14 |
15 import '../scanner/token.dart' show BeginGroupToken; | 15 import '../scanner/token.dart' show BeginGroupToken; |
16 | 16 |
17 import '../../scanner/token.dart' show Token; | 17 import '../../scanner/token.dart' show Token; |
18 | 18 |
19 // TODO(ahe): Move this to parser package. | 19 // TODO(ahe): Move this to parser package. |
20 class DietParser extends ClassMemberParser { | 20 class DietParser extends ClassMemberParser { |
21 DietParser(Listener listener) : super(listener); | 21 DietParser(Listener listener) : super(listener); |
22 | 22 |
23 Token parseFormalParameters(Token token, {bool inFunctionType: false}) { | 23 Token parseFormalParameters(Token token, MemberKind kind) { |
24 return skipFormals(token); | 24 return skipFormals(token, kind); |
25 } | 25 } |
26 | 26 |
27 Token skipFormals(Token token) { | 27 Token skipFormals(Token token, MemberKind kind) { |
28 listener.beginOptionalFormalParameters(token); | 28 listener.beginOptionalFormalParameters(token); |
29 if (!optional('(', token)) { | 29 if (!optional('(', token)) { |
30 if (optional(';', token)) { | 30 if (optional(';', token)) { |
31 reportRecoverableErrorCode(token, codeExpectedOpenParens); | 31 reportRecoverableErrorCode(token, codeExpectedOpenParens); |
32 return token; | 32 return token; |
33 } | 33 } |
34 return reportUnexpectedToken(token).next; | 34 return reportUnexpectedToken(token).next; |
35 } | 35 } |
36 BeginGroupToken beginGroupToken = token; | 36 BeginGroupToken beginGroupToken = token; |
37 Token endToken = beginGroupToken.endGroup; | 37 Token endToken = beginGroupToken.endGroup; |
38 listener.endFormalParameters(0, token, endToken); | 38 listener.endFormalParameters(0, token, endToken, kind); |
39 return endToken.next; | 39 return endToken.next; |
40 } | 40 } |
41 } | 41 } |
OLD | NEW |