OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style licenset hat can be found in the LICENSE file. |
| 4 |
| 5 library dart_scanner.recover; |
| 6 |
| 7 import 'token.dart' show |
| 8 Token; |
| 9 |
| 10 /// Recover from errors in [tokens]. The original sources are provided as |
| 11 /// [bytes]. [lineStarts] are the beginning character offsets of lines, and |
| 12 /// must be updated if recovery is performed rewriting the original source |
| 13 /// code. |
| 14 Token defaultRecoveryStrategy( |
| 15 List<int> bytes, Token tokens, List<int> lineStarts) { |
| 16 // See [Parser.reportErrorToken](package:dart_parser/src/parser.dart) for how |
| 17 // it currently handles lexical errors. In addition, notice how the parser |
| 18 // calls [handleInvalidExpression], [handleInvalidFunctionBody], and |
| 19 // [handleInvalidTypeReference] to allow the listener to recover its internal |
| 20 // state. See [package:compiler/src/parser/element_listener.dart] for an |
| 21 // example of how these events are used. |
| 22 // |
| 23 // In addition, the scanner will attempt a bit of recovery when braces don't |
| 24 // match up during brace grouping. See |
| 25 // [ArrayBasedScanner.discardBeginGroupUntil](array_based_scanner.dart). For |
| 26 // more details on brace grouping see |
| 27 // [AbstractScanner.unmatchedBeginGroup](abstract_scanner.dart). |
| 28 return tokens; |
| 29 } |
OLD | NEW |