| 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 3507 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3518 | 3518 |
| 3519 /// Don't call this method. Should only be used as a last resort when there | 3519 /// Don't call this method. Should only be used as a last resort when there |
| 3520 /// is no feasible way to recover from a parser error. | 3520 /// is no feasible way to recover from a parser error. |
| 3521 Token reportUnrecoverableError(Token token, ErrorKind kind, [Map arguments]) { | 3521 Token reportUnrecoverableError(Token token, ErrorKind kind, [Map arguments]) { |
| 3522 Token next; | 3522 Token next; |
| 3523 if (token is ErrorToken) { | 3523 if (token is ErrorToken) { |
| 3524 next = reportErrorToken(token, false); | 3524 next = reportErrorToken(token, false); |
| 3525 } else { | 3525 } else { |
| 3526 arguments ??= {}; | 3526 arguments ??= {}; |
| 3527 arguments.putIfAbsent("actual", () => token.value); | 3527 arguments.putIfAbsent("actual", () => token.value); |
| 3528 next = listener.handleUnrecoverableError(token, kind, arguments); | 3528 next = listener.handleUnrecoverableError(token, kind, arguments)?.next; |
| 3529 } | 3529 } |
| 3530 return next ?? skipToEof(token); | 3530 return next ?? skipToEof(token); |
| 3531 } | 3531 } |
| 3532 | 3532 |
| 3533 void reportRecoverableError(Token token, ErrorKind kind, [Map arguments]) { | 3533 void reportRecoverableError(Token token, ErrorKind kind, [Map arguments]) { |
| 3534 if (token is ErrorToken) { | 3534 if (token is ErrorToken) { |
| 3535 reportErrorToken(token, true); | 3535 reportErrorToken(token, true); |
| 3536 } else { | 3536 } else { |
| 3537 arguments ??= {}; | 3537 arguments ??= {}; |
| 3538 listener.handleRecoverableError(token, kind, arguments); | 3538 listener.handleRecoverableError(token, kind, arguments); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 3569 arguments = {"text": token.assertionMessage}; | 3569 arguments = {"text": token.assertionMessage}; |
| 3570 break; | 3570 break; |
| 3571 | 3571 |
| 3572 default: | 3572 default: |
| 3573 break; | 3573 break; |
| 3574 } | 3574 } |
| 3575 if (isRecoverable) { | 3575 if (isRecoverable) { |
| 3576 listener.handleRecoverableError(token, kind, arguments); | 3576 listener.handleRecoverableError(token, kind, arguments); |
| 3577 return null; | 3577 return null; |
| 3578 } else { | 3578 } else { |
| 3579 return listener.handleUnrecoverableError(token, kind, arguments); | 3579 return listener.handleUnrecoverableError(token, kind, arguments)?.next; |
| 3580 } | 3580 } |
| 3581 } | 3581 } |
| 3582 } | 3582 } |
| OLD | NEW |