Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(327)

Unified Diff: pkg/dart_scanner/lib/src/recover.dart

Issue 2654433009: Skeleton for lexical error recovery. (Closed)
Patch Set: Address comments. Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/dart_scanner/lib/src/array_based_scanner.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/dart_scanner/lib/src/recover.dart
diff --git a/pkg/dart_scanner/lib/src/recover.dart b/pkg/dart_scanner/lib/src/recover.dart
new file mode 100644
index 0000000000000000000000000000000000000000..837274717e592b6404814bf5d0b5b8deba51b598
--- /dev/null
+++ b/pkg/dart_scanner/lib/src/recover.dart
@@ -0,0 +1,29 @@
+// Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style licenset hat can be found in the LICENSE file.
+
+library dart_scanner.recover;
+
+import 'token.dart' show
+ Token;
+
+/// Recover from errors in [tokens]. The original sources are provided as
+/// [bytes]. [lineStarts] are the beginning character offsets of lines, and
+/// must be updated if recovery is performed rewriting the original source
+/// code.
+Token defaultRecoveryStrategy(
+ List<int> bytes, Token tokens, List<int> lineStarts) {
+ // See [Parser.reportErrorToken](package:dart_parser/src/parser.dart) for how
+ // it currently handles lexical errors. In addition, notice how the parser
+ // calls [handleInvalidExpression], [handleInvalidFunctionBody], and
+ // [handleInvalidTypeReference] to allow the listener to recover its internal
+ // state. See [package:compiler/src/parser/element_listener.dart] for an
+ // example of how these events are used.
+ //
+ // In addition, the scanner will attempt a bit of recovery when braces don't
+ // match up during brace grouping. See
+ // [ArrayBasedScanner.discardBeginGroupUntil](array_based_scanner.dart). For
+ // more details on brace grouping see
+ // [AbstractScanner.unmatchedBeginGroup](abstract_scanner.dart).
+ return tokens;
+}
« no previous file with comments | « pkg/dart_scanner/lib/src/array_based_scanner.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698