| 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/precedence.dart' | |
| 8 show BAD_INPUT_INFO, EOF_INFO; | |
| 9 import 'package:front_end/src/fasta/scanner/recover.dart' | 7 import 'package:front_end/src/fasta/scanner/recover.dart' |
| 10 show defaultRecoveryStrategy; | 8 show defaultRecoveryStrategy; |
| 11 import 'package:front_end/src/fasta/scanner.dart' as fasta; | 9 import 'package:front_end/src/fasta/scanner.dart' as fasta; |
| 12 import 'package:front_end/src/fasta/scanner/token.dart' as fasta; | 10 import 'package:front_end/src/fasta/scanner/token.dart' as fasta; |
| 13 import 'package:front_end/src/fasta/scanner/error_token.dart' as fasta; | 11 import 'package:front_end/src/fasta/scanner/error_token.dart' as fasta; |
| 14 import 'package:front_end/src/scanner/token.dart' as analyzer; | 12 import 'package:front_end/src/scanner/token.dart' as analyzer; |
| 15 import 'package:front_end/src/scanner/errors.dart' | 13 import 'package:front_end/src/scanner/errors.dart' |
| 16 show ScannerErrorCode, translateErrorToken; | 14 show ScannerErrorCode, translateErrorToken; |
| 17 import 'package:test/test.dart'; | 15 import 'package:test/test.dart'; |
| 18 import 'package:test_reflective_loader/test_reflective_loader.dart'; | 16 import 'package:test_reflective_loader/test_reflective_loader.dart'; |
| (...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 328 genericMethodComments: genericMethodComments, | 326 genericMethodComments: genericMethodComments, |
| 329 lazyAssignmentOperators: lazyAssignmentOperators); | 327 lazyAssignmentOperators: lazyAssignmentOperators); |
| 330 listener.assertNoErrors(); | 328 listener.assertNoErrors(); |
| 331 return token; | 329 return token; |
| 332 } | 330 } |
| 333 | 331 |
| 334 analyzer.Token extractErrors(fasta.Token firstToken, ErrorListener listener) { | 332 analyzer.Token extractErrors(fasta.Token firstToken, ErrorListener listener) { |
| 335 var token = firstToken; | 333 var token = firstToken; |
| 336 // The default recovery strategy used by scanString | 334 // The default recovery strategy used by scanString |
| 337 // places all error tokens at the head of the stream. | 335 // places all error tokens at the head of the stream. |
| 338 while (token.info == BAD_INPUT_INFO) { | 336 while (token.info == analyzer.TokenType.BAD_INPUT) { |
| 339 translateErrorToken(token, | 337 translateErrorToken(token, |
| 340 (ScannerErrorCode errorCode, int offset, List<Object> arguments) { | 338 (ScannerErrorCode errorCode, int offset, List<Object> arguments) { |
| 341 listener.errors.add(new TestError(offset, errorCode, arguments)); | 339 listener.errors.add(new TestError(offset, errorCode, arguments)); |
| 342 }); | 340 }); |
| 343 token = token.next; | 341 token = token.next; |
| 344 } | 342 } |
| 345 if (!token.previousToken.isEof) { | 343 if (!token.previousToken.isEof) { |
| 346 var head = new fasta.SymbolToken(EOF_INFO, -1); | 344 var head = new fasta.SymbolToken(analyzer.TokenType.EOF, -1); |
| 347 token.previous = head; | 345 token.previous = head; |
| 348 head.next = token; | 346 head.next = token; |
| 349 } | 347 } |
| 350 return token; | 348 return token; |
| 351 } | 349 } |
| 352 | 350 |
| 353 /// Assert that the tokens in the stream are correctly connected prev/next. | 351 /// Assert that the tokens in the stream are correctly connected prev/next. |
| 354 void assertValidTokenStream(fasta.Token firstToken, | 352 void assertValidTokenStream(fasta.Token firstToken, |
| 355 {bool errorsFirst: false}) { | 353 {bool errorsFirst: false}) { |
| 356 fasta.Token token = firstToken; | 354 fasta.Token token = firstToken; |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 392 } else if (token is fasta.UnmatchedToken) { | 390 } else if (token is fasta.UnmatchedToken) { |
| 393 expect(lastClosedGroup?.endGroup?.next, same(token), | 391 expect(lastClosedGroup?.endGroup?.next, same(token), |
| 394 reason: 'Unexpected error token for group: $lastClosedGroup'); | 392 reason: 'Unexpected error token for group: $lastClosedGroup'); |
| 395 expect(token.begin, lastClosedGroup); | 393 expect(token.begin, lastClosedGroup); |
| 396 } | 394 } |
| 397 token = token.next; | 395 token = token.next; |
| 398 } | 396 } |
| 399 expect(openerStack, isEmpty, reason: 'Missing closers'); | 397 expect(openerStack, isEmpty, reason: 'Missing closers'); |
| 400 } | 398 } |
| 401 } | 399 } |
| OLD | NEW |