| OLD | NEW |
| 1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2017, 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 import 'dart:convert' show UTF8; | 5 import 'dart:convert' show UTF8; |
| 6 | 6 |
| 7 import 'package:front_end/src/fasta/scanner/recover.dart' | 7 import 'package:front_end/src/fasta/scanner/recover.dart' |
| 8 show defaultRecoveryStrategy; | 8 show defaultRecoveryStrategy; |
| 9 import 'package:front_end/src/fasta/scanner.dart' as fasta; | 9 import 'package:front_end/src/fasta/scanner.dart' as fasta; |
| 10 import 'package:front_end/src/fasta/scanner/token.dart' as fasta; | 10 import 'package:front_end/src/fasta/scanner/token.dart' as fasta; |
| (...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 305 genericMethodComments: genericMethodComments, | 305 genericMethodComments: genericMethodComments, |
| 306 lazyAssignmentOperators: lazyAssignmentOperators); | 306 lazyAssignmentOperators: lazyAssignmentOperators); |
| 307 listener.assertNoErrors(); | 307 listener.assertNoErrors(); |
| 308 return token; | 308 return token; |
| 309 } | 309 } |
| 310 | 310 |
| 311 analyzer.Token extractErrors(fasta.Token firstToken, ErrorListener listener) { | 311 analyzer.Token extractErrors(fasta.Token firstToken, ErrorListener listener) { |
| 312 var token = firstToken; | 312 var token = firstToken; |
| 313 // The default recovery strategy used by scanString | 313 // The default recovery strategy used by scanString |
| 314 // places all error tokens at the head of the stream. | 314 // places all error tokens at the head of the stream. |
| 315 while (token.info == analyzer.TokenType.BAD_INPUT) { | 315 while (token.type == analyzer.TokenType.BAD_INPUT) { |
| 316 translateErrorToken(token, | 316 translateErrorToken(token, |
| 317 (ScannerErrorCode errorCode, int offset, List<Object> arguments) { | 317 (ScannerErrorCode errorCode, int offset, List<Object> arguments) { |
| 318 listener.errors.add(new TestError(offset, errorCode, arguments)); | 318 listener.errors.add(new TestError(offset, errorCode, arguments)); |
| 319 }); | 319 }); |
| 320 token = token.next; | 320 token = token.next; |
| 321 } | 321 } |
| 322 if (!token.previousToken.isEof) { | 322 if (!token.previousToken.isEof) { |
| 323 var head = new fasta.SymbolToken(analyzer.TokenType.EOF, -1); | 323 var head = new fasta.SymbolToken(analyzer.TokenType.EOF, -1); |
| 324 token.previous = head; | 324 token.previous = head; |
| 325 head.next = token; | 325 head.next = token; |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 369 } else if (token is fasta.UnmatchedToken) { | 369 } else if (token is fasta.UnmatchedToken) { |
| 370 expect(lastClosedGroup?.endGroup?.next, same(token), | 370 expect(lastClosedGroup?.endGroup?.next, same(token), |
| 371 reason: 'Unexpected error token for group: $lastClosedGroup'); | 371 reason: 'Unexpected error token for group: $lastClosedGroup'); |
| 372 expect(token.begin, lastClosedGroup); | 372 expect(token.begin, lastClosedGroup); |
| 373 } | 373 } |
| 374 token = token.next; | 374 token = token.next; |
| 375 } | 375 } |
| 376 expect(openerStack, isEmpty, reason: 'Missing closers'); | 376 expect(openerStack, isEmpty, reason: 'Missing closers'); |
| 377 } | 377 } |
| 378 } | 378 } |
| OLD | NEW |