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

Unified Diff: pkg/front_end/lib/src/fasta/scanner/array_based_scanner.dart

Issue 2910583002: improve fasta interpolation recovery (Closed)
Patch Set: remove unnecessary label Created 3 years, 7 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
Index: pkg/front_end/lib/src/fasta/scanner/array_based_scanner.dart
diff --git a/pkg/front_end/lib/src/fasta/scanner/array_based_scanner.dart b/pkg/front_end/lib/src/fasta/scanner/array_based_scanner.dart
index a05e0f44798bb38195266815410628cd9f109f15..1eb5ffb39151ac09fb1dfd829ca73ee356586dcb 100644
--- a/pkg/front_end/lib/src/fasta/scanner/array_based_scanner.dart
+++ b/pkg/front_end/lib/src/fasta/scanner/array_based_scanner.dart
@@ -122,7 +122,7 @@ abstract class ArrayBasedScanner extends AbstractScanner {
/**
* Appends a token that begins a new group, represented by [type].
- * Group begin tokens are '{', '(', '[' and '${'.
+ * Group begin tokens are '{', '(', '[', '<' and '${'.
*/
void appendBeginGroup(TokenType type) {
Token token = new BeginTokenWithComment(type, tokenStart, comments);
@@ -257,6 +257,20 @@ abstract class ArrayBasedScanner extends AbstractScanner {
}
}
+ /**
+ * This method is called to discard '${' from the "grouping" stack.
+ *
+ * This method is called when the scanner finds the end of a string
+ * or an unterminated string.
ahe 2017/05/31 13:15:48 I think this is only called when it finds an unter
danrubel 2017/06/01 19:02:46 Right. Fixed in https://codereview.chromium.org/29
+ */
+ void discardInterpolation() {
+ if (groupingStack.isEmpty) return;
+ BeginToken begin = groupingStack.head;
+ if (begin.kind != STRING_INTERPOLATION_TOKEN) return;
+ unmatchedBeginGroup(begin);
+ groupingStack = groupingStack.tail;
ahe 2017/05/31 13:15:48 What happens in this case: "${([{
danrubel 2017/06/01 19:02:46 Hmmm... good point. Fixed in https://codereview.ch
+ }
+
void unmatchedBeginGroup(BeginToken begin) {
// We want to ensure that unmatched BeginTokens are reported as
// errors. However, the diet parser assumes that groups are well-balanced

Powered by Google App Engine
This is Rietveld 408576698