| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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.parser; | 5 library fasta.parser.parser; |
| 6 | 6 |
| 7 import '../fasta_codes.dart' show Code, Message, Template; | 7 import '../fasta_codes.dart' show Code, Message, Template; |
| 8 | 8 |
| 9 import '../fasta_codes.dart' as fasta; | 9 import '../fasta_codes.dart' as fasta; |
| 10 | 10 |
| (...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 279 token = token.next; | 279 token = token.next; |
| 280 } | 280 } |
| 281 if (token.isTopLevelKeyword) { | 281 if (token.isTopLevelKeyword) { |
| 282 Token abstractToken; | 282 Token abstractToken; |
| 283 Token modifierToken = start; | 283 Token modifierToken = start; |
| 284 while (modifierToken != token) { | 284 while (modifierToken != token) { |
| 285 if (optional('abstract', modifierToken) && | 285 if (optional('abstract', modifierToken) && |
| 286 optional('class', token) && | 286 optional('class', token) && |
| 287 abstractToken == null) { | 287 abstractToken == null) { |
| 288 abstractToken = modifierToken; | 288 abstractToken = modifierToken; |
| 289 } else if (optional('const', modifierToken) && |
| 290 optional('class', token)) { |
| 291 reportRecoverableError(modifierToken, fasta.messageConstClass); |
| 289 } else { | 292 } else { |
| 290 // TODO(danrubel): Report more specific recoverable error message | |
| 291 // for `const class` to better help the user. | |
| 292 // See ParserErrorCode CONST_CLASS | |
| 293 | |
| 294 // Report an error for each extraneous modifier | |
| 295 reportRecoverableErrorWithToken( | 293 reportRecoverableErrorWithToken( |
| 296 modifierToken, fasta.templateExtraneousModifier); | 294 modifierToken, fasta.templateExtraneousModifier); |
| 297 } | 295 } |
| 298 modifierToken = modifierToken.next; | 296 modifierToken = modifierToken.next; |
| 299 } | 297 } |
| 300 return parseTopLevelKeywordDeclaration(abstractToken, token); | 298 return parseTopLevelKeywordDeclaration(abstractToken, token); |
| 301 } else if (token.isIdentifier || token.keyword != null) { | 299 } else if (token.isIdentifier || token.keyword != null) { |
| 302 // TODO(danrubel): improve parseTopLevelMember | 300 // TODO(danrubel): improve parseTopLevelMember |
| 303 // so that we don't parse modifiers twice. | 301 // so that we don't parse modifiers twice. |
| 304 return parseTopLevelMember(start); | 302 return parseTopLevelMember(start); |
| (...skipping 3878 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4183 } | 4181 } |
| 4184 | 4182 |
| 4185 Token reportUnexpectedToken(Token token) { | 4183 Token reportUnexpectedToken(Token token) { |
| 4186 return reportUnrecoverableErrorWithToken( | 4184 return reportUnrecoverableErrorWithToken( |
| 4187 token, fasta.templateUnexpectedToken); | 4185 token, fasta.templateUnexpectedToken); |
| 4188 } | 4186 } |
| 4189 } | 4187 } |
| 4190 | 4188 |
| 4191 // TODO(ahe): Remove when analyzer supports generalized function syntax. | 4189 // TODO(ahe): Remove when analyzer supports generalized function syntax. |
| 4192 typedef _MessageWithArgument<T> = Message Function(T); | 4190 typedef _MessageWithArgument<T> = Message Function(T); |
| OLD | NEW |