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 '../scanner.dart' show ErrorToken; | 7 import '../scanner.dart' show ErrorToken; |
8 | 8 |
9 import '../scanner/recover.dart' show closeBraceFor, skipToEof; | 9 import '../scanner/recover.dart' show closeBraceFor, skipToEof; |
10 | 10 |
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
341 listener.endPart(partKeyword, semicolon); | 341 listener.endPart(partKeyword, semicolon); |
342 return token; | 342 return token; |
343 } | 343 } |
344 | 344 |
345 Token parsePartOf(Token token) { | 345 Token parsePartOf(Token token) { |
346 listener.beginPartOf(token); | 346 listener.beginPartOf(token); |
347 assert(optional('part', token)); | 347 assert(optional('part', token)); |
348 assert(optional('of', token.next)); | 348 assert(optional('of', token.next)); |
349 Token partKeyword = token; | 349 Token partKeyword = token; |
350 token = token.next.next; | 350 token = token.next.next; |
351 if (token.isIdentifier()) { | 351 bool hasName = token.isIdentifier(); |
| 352 if (hasName) { |
352 token = parseQualified(token, IdentifierContext.partName, | 353 token = parseQualified(token, IdentifierContext.partName, |
353 IdentifierContext.partNameContinuation); | 354 IdentifierContext.partNameContinuation); |
354 } else { | 355 } else { |
355 token = parseLiteralStringOrRecoverExpression(token); | 356 token = parseLiteralStringOrRecoverExpression(token); |
356 } | 357 } |
357 Token semicolon = token; | 358 Token semicolon = token; |
358 token = expect(';', token); | 359 token = expect(';', token); |
359 listener.endPartOf(partKeyword, semicolon); | 360 listener.endPartOf(partKeyword, semicolon, hasName); |
360 return token; | 361 return token; |
361 } | 362 } |
362 | 363 |
363 Token parseMetadataStar(Token token, {bool forParameter: false}) { | 364 Token parseMetadataStar(Token token, {bool forParameter: false}) { |
364 listener.beginMetadataStar(token); | 365 listener.beginMetadataStar(token); |
365 int count = 0; | 366 int count = 0; |
366 while (optional('@', token)) { | 367 while (optional('@', token)) { |
367 token = parseMetadata(token); | 368 token = parseMetadata(token); |
368 count++; | 369 count++; |
369 } | 370 } |
(...skipping 3227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3597 break; | 3598 break; |
3598 } | 3599 } |
3599 if (isRecoverable) { | 3600 if (isRecoverable) { |
3600 listener.handleRecoverableError(token, kind, arguments); | 3601 listener.handleRecoverableError(token, kind, arguments); |
3601 return null; | 3602 return null; |
3602 } else { | 3603 } else { |
3603 return listener.handleUnrecoverableError(token, kind, arguments); | 3604 return listener.handleUnrecoverableError(token, kind, arguments); |
3604 } | 3605 } |
3605 } | 3606 } |
3606 } | 3607 } |
OLD | NEW |