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 { |