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