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

Side by Side Diff: dart/frog/leg/scanner/array_based_scanner.dart

Issue 9112008: Improve error recovery in parser. (Closed) Base URL: ssh://aaricia.aar/home/ahe/Dart/all/dart.googlecode.com.git@master
Patch Set: Update language-leg.status Created 8 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 unified diff | Download patch
« no previous file with comments | « no previous file | dart/frog/leg/scanner/listener.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 class ArrayBasedScanner<S> extends AbstractScanner<S> { 5 class ArrayBasedScanner<S> extends AbstractScanner<S> {
6 int get charOffset() => byteOffset + extraCharOffset; 6 int get charOffset() => byteOffset + extraCharOffset;
7 final Token tokens; 7 final Token tokens;
8 Token tail; 8 Token tail;
9 int tokenStart; 9 int tokenStart;
10 int byteOffset; 10 int byteOffset;
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 groupingStack.head.kind === LT_TOKEN) { 85 groupingStack.head.kind === LT_TOKEN) {
86 groupingStack = groupingStack.tail; 86 groupingStack = groupingStack.tail;
87 } 87 }
88 groupingStack = groupingStack.prepend(token); 88 groupingStack = groupingStack.prepend(token);
89 } 89 }
90 90
91 int appendEndGroup(PrecedenceInfo info, String value, int openKind) { 91 int appendEndGroup(PrecedenceInfo info, String value, int openKind) {
92 assert(openKind !== LT_TOKEN); 92 assert(openKind !== LT_TOKEN);
93 appendStringToken(info, value); 93 appendStringToken(info, value);
94 if (groupingStack.isEmpty()) { 94 if (groupingStack.isEmpty()) {
95 throw new MalformedInputException('Unmatched $value'); 95 return advance();
96 } 96 }
97 discardOpenLt(); 97 discardOpenLt();
98 BeginGroupToken begin = groupingStack.head; 98 BeginGroupToken begin = groupingStack.head;
99 if (begin.kind !== openKind) { 99 if (begin.kind !== openKind) {
100 if (openKind !== OPEN_CURLY_BRACKET_TOKEN || 100 if (openKind !== OPEN_CURLY_BRACKET_TOKEN ||
101 begin.kind !== STRING_INTERPOLATION_TOKEN) { 101 begin.kind !== STRING_INTERPOLATION_TOKEN) {
102 // Not ending string interpolation. 102 // Not ending string interpolation.
103 throw new MalformedInputException('Unmatched ${begin.stringValue}'); 103 throw new MalformedInputException('Unmatched ${begin.stringValue}');
104 } 104 }
105 // We're ending an interpolated expression. 105 // We're ending an interpolated expression.
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 groupingStack = groupingStack.tail; 152 groupingStack = groupingStack.tail;
153 } 153 }
154 } 154 }
155 155
156 void discardOpenLt() { 156 void discardOpenLt() {
157 while (!groupingStack.isEmpty() && groupingStack.head.kind === LT_TOKEN) { 157 while (!groupingStack.isEmpty() && groupingStack.head.kind === LT_TOKEN) {
158 groupingStack = groupingStack.tail; 158 groupingStack = groupingStack.tail;
159 } 159 }
160 } 160 }
161 } 161 }
OLDNEW
« no previous file with comments | « no previous file | dart/frog/leg/scanner/listener.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698