anchor.diff:    }
   
     /**
  -   * Parse the given [source] as a statement. If [enableLazyAssignmentOperators]
  +   * Parse the given [content] as a statement. If [enableLazyAssignmentOperators]
      * is `true`, then lazy assignment operators should be enabled.
      */
  -  Statement parseStatement(String source,
  +  Statement parseStatement(String content,
         {bool enableLazyAssignmentOperators, int expectedEndOffset}) {
  +    Source source = new TestSource();
       listener = new GatheringErrorListener();
  -    Scanner scanner =
  -        new Scanner(null, new CharSequenceReader(source), listener);
  -    scanner.scanGenericMethodComments = enableGenericMethodComments;
       if (enableLazyAssignmentOperators != null) {
  -      scanner.scanLazyAssignmentOperators = enableLazyAssignmentOperators;
  +      this.enableLazyAssignmentOperators = enableLazyAssignmentOperators;
       }
  -    var testSource = new TestSource();
  -    listener.setLineInfo(testSource, scanner.lineStarts);
  -    Token token = scanner.tokenize();
  -    Parser parser = new Parser(testSource, listener);
  +
  +    void reportError(
  +        ScannerErrorCode errorCode, int offset, List<Object> arguments) {
  +      listener
  +          .onError(new AnalysisError(source, offset, 1, errorCode, arguments));
  +    }
  +
  +    //
  +    // Scan the source.
  +    //
  +    ScannerResult result = scanString(content,
  +        includeComments: true,
  +        scanGenericMethodComments: enableGenericMethodComments,
  +        scanLazyAssignmentOperators: enableLazyAssignmentOperators);
  +    Token token = result.tokens;
  +    if (result.hasErrors) {
  +      // The default recovery strategy used by scanString
  +      // places all error tokens at the head of the stream.
  +      while (token.type == TokenType.BAD_INPUT) {
  +        translateErrorToken(token, reportError);
  +        token = token.next;
  +      }
  +    }
  +    listener.setLineInfo(source, result.lineStarts);
  +
  +    Parser parser = new Parser(source, listener);
       parser.parseGenericMethodComments = enableGenericMethodComments;
       parser.enableOptionalNewAndConst = enableOptionalNewAndConst;
       Statement statement = parser.parseStatement(token);
  
positive.code:    * @throws Exception if the source could not be parsed, if the compilation errors in the source do
     *           not match those that are expected, or if the result would have been `null`
     */
    CompilationUnit parseCompilationUnit(String source,
        {List<ErrorCode> codes, List<ExpectedError> errors}) {
      GatheringErrorListener listener = new GatheringErrorListener();
      Scanner scanner =
          new Scanner(null, new CharSequenceReader(source), listener);
      TestSource testSource = new TestSource();
      listener.setLineInfo(testSource, scanner.lineStarts);
      Token token = scanner.tokenize();
      Parser parser = new Parser(testSource, listener);
      parser.enableOptionalNewAndConst = enableOptionalNewAndConst;
      CompilationUnit unit = parser.parseCompilationUnit(token);
      expect(unit, isNotNull);
  
negative.code: import 'package:analyzer/error/listener.dart';
  import 'package:analyzer/src/dart/ast/token.dart';
  import 'package:analyzer/src/dart/error/hint_codes.dart';
  import 'package:analyzer/src/error/codes.dart';
  import 'package:analyzer/src/generated/parser.dart';
  import 'package:analyzer/src/generated/source.dart';
  import 'package:analyzer/src/generated/testing/token_factory.dart';
  import 'package:analyzer/src/generated/utilities_dart.dart';
  import 'package:front_end/src/fasta/scanner.dart'
      show ScannerResult, scanString;
  import 'package:front_end/src/fasta/scanner/abstract_scanner.dart'
      show AbstractScanner;
  import 'package:front_end/src/scanner/errors.dart';
  import 'package:test/test.dart';
  import 'package:test_reflective_loader/test_reflective_loader.dart';
  
  