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 fasta.parser.class_member_parser; | 5 library fasta.parser.class_member_parser; |
6 | 6 |
7 import '../../scanner/token.dart' show Token; | 7 import '../../scanner/token.dart' show Token; |
8 | 8 |
| 9 import '../fasta_codes.dart' show FastaMessage; |
| 10 |
9 import 'listener.dart' show Listener; | 11 import 'listener.dart' show Listener; |
10 | 12 |
11 import 'parser.dart' show Parser; | 13 import 'parser.dart' show Assert, Parser; |
12 | 14 |
13 /// Parser similar to [TopLevelParser] but also parses class members (excluding | 15 /// Parser similar to [TopLevelParser] but also parses class members (excluding |
14 /// their bodies). | 16 /// their bodies). |
15 class ClassMemberParser extends Parser { | 17 class ClassMemberParser extends Parser { |
16 ClassMemberParser(Listener listener) : super(listener); | 18 ClassMemberParser(Listener listener) : super(listener); |
17 | 19 |
| 20 @override |
18 Token parseExpression(Token token) => skipExpression(token); | 21 Token parseExpression(Token token) => skipExpression(token); |
19 | 22 |
20 Token parseRecoverExpression(Token token) { | 23 @override |
| 24 Token parseAssert(Token token, Assert kind) { |
| 25 if (kind == Assert.Statement) { |
| 26 return super.parseAssert(token, kind); |
| 27 } else { |
| 28 return skipExpression(token); |
| 29 } |
| 30 } |
| 31 |
| 32 Token parseRecoverExpression(Token token, FastaMessage message) { |
21 Token begin = token; | 33 Token begin = token; |
22 token = skipExpression(token); | 34 token = skipExpression(token); |
23 listener.handleRecoverExpression(begin); | 35 listener.handleRecoverExpression(begin, message); |
24 return token; | 36 return token; |
25 } | 37 } |
26 | 38 |
27 // This method is overridden for two reasons: | 39 // This method is overridden for two reasons: |
28 // 1. Avoid generating events for arguments. | 40 // 1. Avoid generating events for arguments. |
29 // 2. Avoid calling skip expression for each argument (which doesn't work). | 41 // 2. Avoid calling skip expression for each argument (which doesn't work). |
30 Token parseArgumentsOpt(Token token) => skipArgumentsOpt(token); | 42 Token parseArgumentsOpt(Token token) => skipArgumentsOpt(token); |
31 | 43 |
32 Token parseFunctionBody(Token token, bool isExpression, bool allowAbstract) { | 44 Token parseFunctionBody(Token token, bool isExpression, bool allowAbstract) { |
33 return skipFunctionBody(token, isExpression, allowAbstract); | 45 return skipFunctionBody(token, isExpression, allowAbstract); |
34 } | 46 } |
35 } | 47 } |
OLD | NEW |