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