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

Side by Side Diff: pkg/dart_scanner/lib/src/array_based_scanner.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 unified diff | Download patch
« no previous file with comments | « pkg/dart_scanner/lib/src/abstract_scanner.dart ('k') | pkg/dart_scanner/lib/src/recover.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 library dart_scanner.array_based_scanner; 5 library dart_scanner.array_based_scanner;
6 6
7 import 'keyword.dart' show 7 import 'keyword.dart' show
8 Keyword; 8 Keyword;
9 9
10 import 'precedence.dart' show 10 import 'precedence.dart' show
(...skipping 17 matching lines...) Expand all
28 $LF, 28 $LF,
29 $STX; 29 $STX;
30 30
31 import 'abstract_scanner.dart' show 31 import 'abstract_scanner.dart' show
32 AbstractScanner; 32 AbstractScanner;
33 33
34 import 'package:compiler_util/link.dart' show 34 import 'package:compiler_util/link.dart' show
35 Link; 35 Link;
36 36
37 abstract class ArrayBasedScanner extends AbstractScanner { 37 abstract class ArrayBasedScanner extends AbstractScanner {
38 bool hasErrors = false;
39
38 ArrayBasedScanner(bool includeComments) 40 ArrayBasedScanner(bool includeComments)
39 : super(includeComments); 41 : super(includeComments);
40 42
41 /** 43 /**
42 * The stack of open groups, e.g [: { ... ( .. :] 44 * The stack of open groups, e.g [: { ... ( .. :]
43 * Each BeginGroupToken has a pointer to the token where the group 45 * Each BeginGroupToken has a pointer to the token where the group
44 * ends. This field is set when scanning the end group token. 46 * ends. This field is set when scanning the end group token.
45 */ 47 */
46 Link<BeginGroupToken> groupingStack = const Link<BeginGroupToken>(); 48 Link<BeginGroupToken> groupingStack = const Link<BeginGroupToken>();
47 49
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 groupingStack = groupingStack.tail; 219 groupingStack = groupingStack.tail;
218 } 220 }
219 } 221 }
220 222
221 void appendComment(start, bool asciiOnly) { 223 void appendComment(start, bool asciiOnly) {
222 if (!includeComments) return; 224 if (!includeComments) return;
223 appendSubstringToken(COMMENT_INFO, start, asciiOnly); 225 appendSubstringToken(COMMENT_INFO, start, asciiOnly);
224 } 226 }
225 227
226 void appendErrorToken(ErrorToken token) { 228 void appendErrorToken(ErrorToken token) {
229 hasErrors = true;
227 tail.next = token; 230 tail.next = token;
228 tail = token; 231 tail = token;
229 } 232 }
230 233
231 /** 234 /**
232 * This method is called to discard '<' from the "grouping" stack. 235 * This method is called to discard '<' from the "grouping" stack.
233 * 236 *
234 * [PartialParser.skipExpression] relies on the fact that we do not 237 * [PartialParser.skipExpression] relies on the fact that we do not
235 * create groups for stuff like: 238 * create groups for stuff like:
236 * [:a = b < c, d = e > f:]. 239 * [:a = b < c, d = e > f:].
237 * 240 *
238 * In other words, this method is called when the scanner recognizes 241 * In other words, this method is called when the scanner recognizes
239 * something which cannot possibly be part of a type parameter/argument 242 * something which cannot possibly be part of a type parameter/argument
240 * list, like the '=' in the above example. 243 * list, like the '=' in the above example.
241 */ 244 */
242 void discardOpenLt() { 245 void discardOpenLt() {
243 while (!groupingStack.isEmpty && 246 while (!groupingStack.isEmpty &&
244 identical(groupingStack.head.kind, LT_TOKEN)) { 247 identical(groupingStack.head.kind, LT_TOKEN)) {
245 groupingStack = groupingStack.tail; 248 groupingStack = groupingStack.tail;
246 } 249 }
247 } 250 }
248 } 251 }
OLDNEW
« no previous file with comments | « pkg/dart_scanner/lib/src/abstract_scanner.dart ('k') | pkg/dart_scanner/lib/src/recover.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698