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

Unified Diff: dart/lib/compiler/implementation/scanner/string_scanner.dart

Issue 11092101: Diagnose unbalanced parentheses better. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years, 2 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: dart/lib/compiler/implementation/scanner/string_scanner.dart
diff --git a/dart/lib/compiler/implementation/scanner/string_scanner.dart b/dart/lib/compiler/implementation/scanner/string_scanner.dart
index bdd913107d1d9da977d3e74f6b168c41286bb962..34acd7f085ed77e09d7d3fa97b58d6e3e6c5b286 100644
--- a/dart/lib/compiler/implementation/scanner/string_scanner.dart
+++ b/dart/lib/compiler/implementation/scanner/string_scanner.dart
@@ -32,6 +32,23 @@ class StringScanner extends ArrayBasedScanner<SourceString> {
tail.next = new StringToken.fromSource(info, value, tokenStart);
tail = tail.next;
}
+
+ void unmatchedBeginGroup(BeginGroupToken begin) {
+ SourceString error = new SourceString('unmatched "${begin.stringValue}"');
+ Token close =
+ new StringToken.fromSource(BAD_INPUT_INFO, error, begin.charOffset);
+ // We want to ensure that unmatched BeginGroupTokens are reported
+ // as errors. However, the rest of the parser assume the groups
+ // are well-balanced and will never look at the endGroup
+ // token. This is a nice property that allows us to skip quickly
+ // over correct code. By inserting an additional error token in
+ // the stream, we can keep ignoring endGroup tokens.
+ Token next =
+ new StringToken.fromSource(BAD_INPUT_INFO, error, begin.charOffset);
+ begin.endGroup = close;
+ close.next = next;
+ next.next = begin.next;
+ }
}
class SubstringWrapper implements SourceString {

Powered by Google App Engine
This is Rietveld 408576698