anchor.diff:          : [ParserErrorCode.FINAL_AND_COVARIANT]);
     }
   
  +  void test_covariantAndStatic() {
  +    createParser('covariant static A f;');
  +    ClassMember member = parser.parseClassMember('C');
  +    expectNotNullIfNoErrors(member);
  +    listener.assertErrors(
  +        [expectedError(ParserErrorCode.COVARIANT_AND_STATIC, 10, 6)]);
  +  }
  +
  +  void test_covariantConstructor() {
  +    createParser('class C { covariant C(); }');
  +    ClassDeclaration member = parseFullCompilationUnitMember();
  +    expectNotNullIfNoErrors(member);
  +    listener.assertErrors(
  +        [expectedError(ParserErrorCode.COVARIANT_CONSTRUCTOR, 10, 9)]);
  +  }
  +
  +  void test_covariantMember_getter_noReturnType() {
  +    createParser('static covariant get x => 0;');
  +    ClassMember member = parser.parseClassMember('C');
  +    expectNotNullIfNoErrors(member);
  +    listener
  +        .assertErrors([expectedError(ParserErrorCode.COVARIANT_MEMBER, 7, 9)]);
  +  }
  +
  +  void test_covariantMember_getter_returnType() {
  +    createParser('static covariant int get x => 0;');
  +    ClassMember member = parser.parseClassMember('C');
  +    expectNotNullIfNoErrors(member);
  +    listener
  +        .assertErrors([expectedError(ParserErrorCode.COVARIANT_MEMBER, 7, 9)]);
  +  }
  +
  +  void test_covariantMember_method() {
  +    createParser('covariant int m() => 0;');
  +    ClassMember member = parser.parseClassMember('C');
  +    expectNotNullIfNoErrors(member);
  +    listener
  +        .assertErrors([expectedError(ParserErrorCode.COVARIANT_MEMBER, 0, 9)]);
  +  }
  +
  +  void test_covariantTopLevelDeclaration_class() {
  +    createParser('covariant class C {}');
  +    ClassDeclaration member = parseFullCompilationUnitMember();
  +    expectNotNullIfNoErrors(member);
  +    listener.assertErrors(
  +        [expectedError(ParserErrorCode.COVARIANT_TOP_LEVEL_DECLARATION, 0, 9)]);
  +  }
  +
  +  void test_covariantTopLevelDeclaration_enum() {
  +    createParser('covariant enum E { v }');
  +    EnumDeclaration member = parseFullCompilationUnitMember();
  +    expectNotNullIfNoErrors(member);
  +    listener.assertErrors(
  +        [expectedError(ParserErrorCode.COVARIANT_TOP_LEVEL_DECLARATION, 0, 9)]);
  +  }
  +
  +  void test_covariantTopLevelDeclaration_typedef() {
  +    parseCompilationUnit("covariant typedef F();", errors: [
  +      expectedError(ParserErrorCode.COVARIANT_TOP_LEVEL_DECLARATION, 0, 9)
  +    ]);
  +  }
  +
  +  void test_defaultValueInFunctionType_named_colon() {
  +    createParser('({int x : 0})');
  +    FormalParameter parameter =
  +        parser.parseFormalParameterList(inFunctionType: true).parameters[0];
  +    expectNotNullIfNoErrors(parameter);
  +    listener.assertErrors(
  +        [expectedError(ParserErrorCode.DEFAULT_VALUE_IN_FUNCTION_TYPE, 8, 1)]);
  +  }
  +
  +  void test_defaultValueInFunctionType_named_equal() {
  +    createParser('({int x = 0})');
  +    FormalParameter parameter =
  +        parser.parseFormalParameterList(inFunctionType: true).parameters[0];
  +    expectNotNullIfNoErrors(parameter);
  +    listener.assertErrors(
  +        [expectedError(ParserErrorCode.DEFAULT_VALUE_IN_FUNCTION_TYPE, 8, 1)]);
  +  }
  +
  +  void test_defaultValueInFunctionType_positional() {
  +    createParser('([int x = 0])');
  +    FormalParameter parameter =
  +        parser.parseFormalParameterList(inFunctionType: true).parameters[0];
  +    expectNotNullIfNoErrors(parameter);
  +    listener.assertErrors(
  +        [expectedError(ParserErrorCode.DEFAULT_VALUE_IN_FUNCTION_TYPE, 8, 1)]);
  +  }
  +
  +  void test_directiveAfterDeclaration_classBeforeDirective() {
  +    // TODO(brianwilkerson) Remove codes when highlighting is fixed.
  +    CompilationUnit unit = parseCompilationUnit("class Foo{} library l;",
  +        codes: usingFastaParser
  +            ? [ParserErrorCode.LIBRARY_DIRECTIVE_NOT_FIRST]
  +            : [ParserErrorCode.DIRECTIVE_AFTER_DECLARATION],
  +        errors: usingFastaParser
  +            ? [
  +                expectedError(
  +                    ParserErrorCode.LIBRARY_DIRECTIVE_NOT_FIRST, 12, 10)
  +              ]
  +            : [
  +                expectedError(
  +                    ParserErrorCode.DIRECTIVE_AFTER_DECLARATION, 12, 10)
  +              ]);
  +    expect(unit, isNotNull);
  +  }
  +
  +  void test_directiveAfterDeclaration_classBetweenDirectives() {
  +    // TODO(brianwilkerson) Remove codes when highlighting is fixed.
  +    CompilationUnit unit =
  +        parseCompilationUnit("library l;\nclass Foo{}\npart 'a.dart';", codes: [
  +      ParserErrorCode.DIRECTIVE_AFTER_DECLARATION
  +    ], errors: [
  +      expectedError(ParserErrorCode.DIRECTIVE_AFTER_DECLARATION, 23, 14)
  +    ]);
  +    expect(unit, isNotNull);
  +  }
  +
  +  void test_duplicatedModifier_const() {
  +    createParser('const const m = null;');
  +    ClassMember member = parser.parseClassMember('C');
  +    expectNotNullIfNoErrors(member);
  +    listener.assertErrors(
  +        [expectedError(ParserErrorCode.DUPLICATED_MODIFIER, 6, 5)]);
  +  }
  +
  +  void test_duplicatedModifier_external() {
  +    createParser('external external f();');
  +    ClassMember member = parser.parseClassMember('C');
  +    expectNotNullIfNoErrors(member);
  +    listener.assertErrors(
  +        [expectedError(ParserErrorCode.DUPLICATED_MODIFIER, 9, 8)]);
  +  }
  +
  +  void test_duplicatedModifier_factory() {
  +    createParser('factory factory C() {}');
  +    ClassMember member = parser.parseClassMember('C');
  +    expectNotNullIfNoErrors(member);
  +    listener.assertErrors(
  +        [expectedError(ParserErrorCode.DUPLICATED_MODIFIER, 8, 7)]);
  +  }
  +
  +  void test_duplicatedModifier_final() {
  +    createParser('final final m = null;');
  +    ClassMember member = parser.parseClassMember('C');
  +    expectNotNullIfNoErrors(member);
  +    listener.assertErrors(
  +        [expectedError(ParserErrorCode.DUPLICATED_MODIFIER, 6, 5)]);
  +  }
  +
  +  void test_duplicatedModifier_static() {
  +    createParser('static static var m;');
  +    ClassMember member = parser.parseClassMember('C');
  +    expectNotNullIfNoErrors(member);
  +    listener.assertErrors(
  +        [expectedError(ParserErrorCode.DUPLICATED_MODIFIER, 7, 6)]);
  +  }
  +
  +  void test_duplicatedModifier_var() {
  +    createParser('var var m;');
  +    ClassMember member = parser.parseClassMember('C');
  +    expectNotNullIfNoErrors(member);
  +    listener.assertErrors(
  +        [expectedError(ParserErrorCode.DUPLICATED_MODIFIER, 4, 3)]);
  +  }
  +
  +  void test_duplicateLabelInSwitchStatement() {
  +    SwitchStatement statement =
  +        parseStatement('switch (e) {l1: case 0: break; l1: case 1: break;}');
  +    expectNotNullIfNoErrors(statement);
  +    listener.assertErrors([
  +      expectedError(ParserErrorCode.DUPLICATE_LABEL_IN_SWITCH_STATEMENT, 31, 2)
  +    ]);
  +  }
  +
  +  void test_emptyEnumBody() {
  +    createParser('enum E {}');
  +    EnumDeclaration declaration = parseFullCompilationUnitMember();
  +    expectNotNullIfNoErrors(declaration);
  +    // TODO(brianwilkerson) Convert codes to errors when highlighting is fixed.
  +    listener.assertErrorsWithCodes([ParserErrorCode.EMPTY_ENUM_BODY]);
  +//    listener
  +//        .assertErrors([expectedError(ParserErrorCode.EMPTY_ENUM_BODY, 7, 2),]);
  +  }
  +
  +  void test_enumInClass() {
  +    parseCompilationUnit(r'''
  +class Foo {
  +  enum Bar {
  +    Bar1, Bar2, Bar3
  +  }
  +}
  +''', errors: [expectedError(ParserErrorCode.ENUM_IN_CLASS, 14, 4)]);
  +  }
  +
  +  void test_equalityCannotBeEqualityOperand_eq_eq() {
  +    parseExpression("1 == 2 == 3", errors: [
  +      expectedError(ParserErrorCode.EQUALITY_CANNOT_BE_EQUALITY_OPERAND, 7, 2)
  +    ]);
  +  }
  +
  +  void test_equalityCannotBeEqualityOperand_eq_neq() {
  +    parseExpression("1 == 2 != 3", errors: [
  +      expectedError(ParserErrorCode.EQUALITY_CANNOT_BE_EQUALITY_OPERAND, 7, 2)
  +    ]);
  +  }
  +
  +  void test_equalityCannotBeEqualityOperand_neq_eq() {
  +    parseExpression("1 != 2 == 3", errors: [
  +      expectedError(ParserErrorCode.EQUALITY_CANNOT_BE_EQUALITY_OPERAND, 7, 2)
  +    ]);
  +  }
  +
  +  void test_expectedCaseOrDefault() {
  +    SwitchStatement statement = parseStatement('switch (e) {break;}');
  +    expectNotNullIfNoErrors(statement);
  +    listener.assertErrors(
  +        [expectedError(ParserErrorCode.EXPECTED_CASE_OR_DEFAULT, 12, 5)]);
  +  }
  +
  +  void test_expectedClassMember_inClass_afterType() {
  +    createParser('heart 2 heart');
  +    ClassMember member = parser.parseClassMember('C');
  +    expectNotNullIfNoErrors(member);
  +    listener.assertErrors(
  +        [expectedError(ParserErrorCode.EXPECTED_CLASS_MEMBER, 0, 5)]);
  +  }
  +
  +  void test_expectedClassMember_inClass_beforeType() {
  +    createParser('4 score');
  +    ClassMember member = parser.parseClassMember('C');
  +    expectNotNullIfNoErrors(member);
  +    listener.assertErrors(
  +        [expectedError(ParserErrorCode.EXPECTED_CLASS_MEMBER, 0, 1)]);
  +  }
  +
  +  void test_expectedExecutable_afterAnnotation_atEOF() {
  +    // TODO(brianwilkerson) Remove codes when highlighting is fixed.
  +    parseCompilationUnit('@A',
  +        codes: [ParserErrorCode.EXPECTED_EXECUTABLE],
  +        errors: [expectedError(ParserErrorCode.EXPECTED_EXECUTABLE, 1, 1)]);
  +  }
  +
  +  void test_expectedExecutable_inClass_afterVoid() {
  +    createParser('void 2 void');
  +    ClassMember member = parser.parseClassMember('C');
  +    expectNotNullIfNoErrors(member);
  +    listener.assertErrors(
  +        [expectedError(ParserErrorCode.EXPECTED_EXECUTABLE, 5, 1)]);
  +  }
  +
  +  void test_expectedExecutable_topLevel_afterType() {
  +    createParser('heart 2 heart');
  +    CompilationUnitMember member = parseFullCompilationUnitMember();
  +    expectNotNullIfNoErrors(member);
  +    listener.assertErrors(
  +        [expectedError(ParserErrorCode.EXPECTED_EXECUTABLE, 0, 5)]);
  +  }
  +
  +  void test_expectedExecutable_topLevel_afterVoid() {
  +    createParser('void 2 void');
  +    CompilationUnitMember member = parseFullCompilationUnitMember();
  +    expectNotNullIfNoErrors(member);
  +    listener.assertErrors(
  +        [expectedError(ParserErrorCode.EXPECTED_EXECUTABLE, 5, 1)]);
  +  }
  +
  +  void test_expectedExecutable_topLevel_beforeType() {
  +    createParser('4 score');
  +    CompilationUnitMember member = parseFullCompilationUnitMember();
  +    expectNotNullIfNoErrors(member);
  +    listener.assertErrors(
  +        [expectedError(ParserErrorCode.EXPECTED_EXECUTABLE, 0, 1)]);
  +  }
  +
  +  void test_expectedExecutable_topLevel_eof() {
  +    createParser('x');
  +    CompilationUnitMember member = parseFullCompilationUnitMember();
  +    expectNotNullIfNoErrors(member);
  +    listener.assertErrors(
  +        [expectedError(ParserErrorCode.EXPECTED_EXECUTABLE, 0, 1)]);
  +  }
  +
  +  void test_expectedInterpolationIdentifier() {
  +    StringLiteral literal = parseExpression("'\$x\$'", errors: [
  +      fe.Scanner.useFasta
  +          ? expectedError(ScannerErrorCode.MISSING_IDENTIFIER, 3, 1)
  +          : expectedError(ParserErrorCode.MISSING_IDENTIFIER, 3, 1)
  +    ]);
  +    expectNotNullIfNoErrors(literal);
  +  }
  +
  +  void test_expectedInterpolationIdentifier_emptyString() {
  +    // The scanner inserts an empty string token between the two $'s; we need to
  +    // make sure that the MISSING_IDENTIFIER error that is generated has a
  +    // nonzero width so that it will show up in the editor UI.
  +    StringLiteral literal = parseExpression("'\$\$foo'",
  +//        codes: fe.Scanner.useFasta
  +//            ? [ScannerErrorCode.MISSING_IDENTIFIER]
  +//            : [ParserErrorCode.MISSING_IDENTIFIER],
  +        errors: fe.Scanner.useFasta
  +            ? [expectedError(ScannerErrorCode.MISSING_IDENTIFIER, 2, 1)]
  +            : [expectedError(ParserErrorCode.MISSING_IDENTIFIER, 2, 1)]);
  +    expectNotNullIfNoErrors(literal);
  +  }
  +
  +  @failingTest
  +  void test_expectedListOrMapLiteral() {
  +    // It isn't clear that this test can ever pass. The parser is currently
  +    // create a synthetic list literal in this case, but isSynthetic() isn't
  +    // overridden for ListLiteral. The problem is that the synthetic list
  +    // literals that are being created are not always zero length (because they
  +    // could have type parameters), which violates the contract of
  +    // isSynthetic().
  +    TypedLiteral literal = parseListOrMapLiteral(null, '1');
  +    expectNotNullIfNoErrors(literal);
  +    listener.assertErrors(
  +        [expectedError(ParserErrorCode.EXPECTED_LIST_OR_MAP_LITERAL, 1, 1)]);
  +    expect(literal.isSynthetic, isTrue);
  +  }
  +
  +  void test_expectedStringLiteral() {
  +    StringLiteral literal = parseStringLiteral('1');
  +    expectNotNullIfNoErrors(literal);
  +    listener.assertErrors(
  +        [expectedError(ParserErrorCode.EXPECTED_STRING_LITERAL, 0, 1)]);
  +    expect(literal.isSynthetic, isTrue);
  +  }
  +
  +  void test_expectedToken_commaMissingInArgumentList() {
  +    createParser('(x, y z)');
  +    ArgumentList list = parser.parseArgumentList();
  +    expectNotNullIfNoErrors(list);
  +    listener
  +        .assertErrors([expectedError(ParserErrorCode.EXPECTED_TOKEN, 4, 1)]);
  +  }
  +
  +  void test_expectedToken_parseStatement_afterVoid() {
  +    parseStatement("void}");
  +    listener.assertErrors([
  +      expectedError(ParserErrorCode.EXPECTED_TOKEN, 4, 1),
  +      expectedError(ParserErrorCode.MISSING_IDENTIFIER, 4, 1)
  +    ]);
  +  }
  +
  +  void test_expectedToken_semicolonMissingAfterExport() {
  +    // TODO(brianwilkerson) Remove codes when highlighting is fixed.
  +    CompilationUnit unit = parseCompilationUnit("export '' class A {}",
  +        codes: [ParserErrorCode.EXPECTED_TOKEN],
  +        errors: [expectedError(ParserErrorCode.EXPECTED_TOKEN, 7, 2)]);
  +    ExportDirective directive = unit.directives[0] as ExportDirective;
  +    expect(directive.uri, isNotNull);
  +    expect(directive.uri.stringValue, '');
  +    expect(directive.uri.beginToken.isSynthetic, false);
  +    expect(directive.uri.isSynthetic, false);
  +    Token semicolon = directive.semicolon;
  +    expect(semicolon, isNotNull);
  +    expect(semicolon.isSynthetic, isTrue);
  +    ClassDeclaration clazz = unit.declarations[0] as ClassDeclaration;
  +    expect(clazz.name.name, 'A');
  +  }
  +
  +  void test_expectedToken_semicolonMissingAfterExpression() {
  +    parseStatement("x");
  +    // TODO(brianwilkerson) Convert codes to errors when highlighting is fixed.
  +    listener.assertErrorsWithCodes([ParserErrorCode.EXPECTED_TOKEN]);
  +//    listener
  +//        .assertErrors([expectedError(ParserErrorCode.EXPECTED_TOKEN, 0, 1)]);
  +  }
  +
  +  void test_expectedToken_semicolonMissingAfterImport() {
  +    // TODO(brianwilkerson) Remove codes when highlighting is fixed.
  +    CompilationUnit unit = parseCompilationUnit("import '' class A {}",
  +        codes: [ParserErrorCode.EXPECTED_TOKEN],
  +        errors: [expectedError(ParserErrorCode.EXPECTED_TOKEN, 7, 2)]);
  +    ImportDirective directive = unit.directives[0] as ImportDirective;
  +    Token semicolon = directive.semicolon;
  +    expect(semicolon, isNotNull);
  +    expect(semicolon.isSynthetic, isTrue);
  +  }
  +
  +  void test_expectedToken_uriAndSemicolonMissingAfterExport() {
  +    CompilationUnit unit = parseCompilationUnit("export class A {}", errors: [
  +      expectedError(ParserErrorCode.EXPECTED_STRING_LITERAL, 7, 5),
  +      expectedError(ParserErrorCode.EXPECTED_TOKEN, 7, 5),
  +    ]);
  +    ExportDirective directive = unit.directives[0] as ExportDirective;
  +    expect(directive.uri, isNotNull);
  +    expect(directive.uri.stringValue, '');
  +    expect(directive.uri.beginToken.isSynthetic, true);
  +    expect(directive.uri.isSynthetic, true);
  +    Token semicolon = directive.semicolon;
  +    expect(semicolon, isNotNull);
  +    expect(semicolon.isSynthetic, isTrue);
  +    ClassDeclaration clazz = unit.declarations[0] as ClassDeclaration;
  +    expect(clazz.name.name, 'A');
  +  }
  +
  +  void test_expectedToken_whileMissingInDoStatement() {
  +    parseStatement("do {} (x);");
  +    listener
  +        .assertErrors([expectedError(ParserErrorCode.EXPECTED_TOKEN, 9, 1)]);
  +  }
  +
  +  void test_expectedTypeName_as() {
  +    parseExpression("x as",
  +        errors: [expectedError(ParserErrorCode.EXPECTED_TYPE_NAME, 4, 0)]);
  +  }
  +
  +  void test_expectedTypeName_as_void() {
  +    parseExpression("x as void)",
  +        errors: [expectedError(ParserErrorCode.EXPECTED_TYPE_NAME, 5, 4)]);
  +  }
  +
  +  void test_expectedTypeName_is() {
  +    parseExpression("x is",
  +        errors: [expectedError(ParserErrorCode.EXPECTED_TYPE_NAME, 4, 0)]);
  +  }
  +
  +  void test_expectedTypeName_is_void() {
  +    parseExpression("x is void)",
  +        errors: [expectedError(ParserErrorCode.EXPECTED_TYPE_NAME, 4, 4)]);
  +  }
  +
  +  void test_exportDirectiveAfterPartDirective() {
  +    parseCompilationUnit("part 'a.dart'; export 'b.dart';", errors: [
  +      expectedError(
  +          ParserErrorCode.EXPORT_DIRECTIVE_AFTER_PART_DIRECTIVE, 15, 6)
  +    ]);
  +  }
  +
  +  void test_externalAfterConst() {
  +    createParser('const external C();');
  +    ClassMember member = parser.parseClassMember('C');
  +    expectNotNullIfNoErrors(member);
  +    listener.assertErrors(
  +        [expectedError(ParserErrorCode.EXTERNAL_AFTER_CONST, 6, 8)]);
  +  }
  +
  +  void test_externalAfterFactory() {
  +    createParser('factory external C();');
  +    ClassMember member = parser.parseClassMember('C');
  +    expectNotNullIfNoErrors(member);
  +    listener.assertErrors(
  +        [expectedError(ParserErrorCode.EXTERNAL_AFTER_FACTORY, 8, 8)]);
  +  }
  +
  +  void test_externalAfterStatic() {
  +    createParser('static external int m();');
  +    ClassMember member = parser.parseClassMember('C');
  +    expectNotNullIfNoErrors(member);
  +    listener.assertErrors(
  +        [expectedError(ParserErrorCode.EXTERNAL_AFTER_STATIC, 7, 8)]);
  +  }
  +
  +  void test_externalClass() {
  +    parseCompilationUnit("external class C {}",
  +        errors: [expectedError(ParserErrorCode.EXTERNAL_CLASS, 0, 8)]);
  +  }
  +
  +  void test_externalConstructorWithBody_factory() {
  +    createParser('external factory C() {}');
  +    ClassMember member = parser.parseClassMember('C');
  +    expectNotNullIfNoErrors(member);
  +    // TODO(brianwilkerson) Convert codes to errors when highlighting is fixed.
  +    listener.assertErrorsWithCodes(
  +        [ParserErrorCode.EXTERNAL_CONSTRUCTOR_WITH_BODY]);
  +//    listener.assertErrors(
  +//        [expectedError(ParserErrorCode.EXTERNAL_CONSTRUCTOR_WITH_BODY, 21, 2)]);
  +  }
  +
  +  void test_externalConstructorWithBody_named() {
  +    createParser('external C.c() {}');
  +    ClassMember member = parser.parseClassMember('C');
  +    expectNotNullIfNoErrors(member);
  +    if (usingFastaParser) {
  +      // TODO(brianwilkerson) Convert codes to errors when highlighting is fixed.
  +      listener
  +          .assertErrorsWithCodes([ParserErrorCode.EXTERNAL_METHOD_WITH_BODY]);
  +//      listener.assertErrors(
  +//          [expectedError(ParserErrorCode.EXTERNAL_METHOD_WITH_BODY, 15, 2)]);
  +    } else {
  +      listener.assertErrorsWithCodes(
  +          [ParserErrorCode.EXTERNAL_CONSTRUCTOR_WITH_BODY]);
  +    }
  +  }
  +
  +  void test_externalEnum() {
  +    parseCompilationUnit("external enum E {ONE}",
  +        errors: [expectedError(ParserErrorCode.EXTERNAL_ENUM, 0, 8)]);
  +  }
  +
  +  void test_externalField_const() {
  +    createParser('external const A f;');
  +    ClassMember member = parser.parseClassMember('C');
  +    expectNotNullIfNoErrors(member);
  +    if (usingFastaParser) {
  +      listener.assertErrors([
  +        expectedError(ParserErrorCode.EXTERNAL_FIELD, 0, 8),
  +        expectedError(CompileTimeErrorCode.CONST_NOT_INITIALIZED, 17, 1)
  +      ]);
  +    } else {
  +      listener.assertErrorsWithCodes([ParserErrorCode.EXTERNAL_FIELD]);
  +    }
  +  }
  +
  +  void test_externalField_final() {
  +    createParser('external final A f;');
  +    ClassMember member = parser.parseClassMember('C');
  +    expectNotNullIfNoErrors(member);
  +    listener
  +        .assertErrors([expectedError(ParserErrorCode.EXTERNAL_FIELD, 0, 8)]);
  +  }
  +
  +  void test_externalField_static() {
  +    createParser('external static A f;');
  +    ClassMember member = parser.parseClassMember('C');
  +    expectNotNullIfNoErrors(member);
  +    listener
  +        .assertErrors([expectedError(ParserErrorCode.EXTERNAL_FIELD, 0, 8)]);
  +  }
  +
  +  void test_externalField_typed() {
  +    createParser('external A f;');
  +    ClassMember member = parser.parseClassMember('C');
  +    expectNotNullIfNoErrors(member);
  +    listener
  +        .assertErrors([expectedError(ParserErrorCode.EXTERNAL_FIELD, 0, 8)]);
  +  }
  +
  +  void test_externalField_untyped() {
  +    createParser('external var f;');
  +    ClassMember member = parser.parseClassMember('C');
  +    expectNotNullIfNoErrors(member);
  +    listener
  +        .assertErrors([expectedError(ParserErrorCode.EXTERNAL_FIELD, 0, 8)]);
  +  }
  +
  +  void test_externalGetterWithBody() {
  +    createParser('external int get x {}');
  +    ClassMember member = parser.parseClassMember('C');
  +    expectNotNullIfNoErrors(member);
  +    if (usingFastaParser) {
  +      // TODO(brianwilkerson) Convert codes to errors when highlighting is fixed.
  +      listener
  +          .assertErrorsWithCodes([ParserErrorCode.EXTERNAL_METHOD_WITH_BODY]);
  +//      listener.assertErrors(
  +//          [expectedError(ParserErrorCode.EXTERNAL_METHOD_WITH_BODY, 19, 2)]);
  +    } else {
  +      listener
  +          .assertErrorsWithCodes([ParserErrorCode.EXTERNAL_GETTER_WITH_BODY]);
  +    }
  +  }
  +
  +  void test_externalMethodWithBody() {
  +    createParser('external m() {}');
  +    ClassMember member = parser.parseClassMember('C');
  +    expectNotNullIfNoErrors(member);
  +    // TODO(brianwilkerson) Convert codes to errors when highlighting is fixed.
  +    listener.assertErrorsWithCodes([ParserErrorCode.EXTERNAL_METHOD_WITH_BODY]);
  +//    listener.assertErrors(
  +//        [expectedError(ParserErrorCode.EXTERNAL_METHOD_WITH_BODY, 13, 2)]);
  +  }
  +
  +  void test_externalOperatorWithBody() {
  +    createParser('external operator +(int value) {}');
  +    ClassMember member = parser.parseClassMember('C');
  +    expectNotNullIfNoErrors(member);
  +    if (usingFastaParser) {
  +      // TODO(brianwilkerson) Convert codes to errors when highlighting is fixed.
  +      listener
  +          .assertErrorsWithCodes([ParserErrorCode.EXTERNAL_METHOD_WITH_BODY]);
  +//      listener.assertErrors(
  +//          [expectedError(ParserErrorCode.EXTERNAL_METHOD_WITH_BODY, 31, 2)]);
  +    } else {
  +      listener
  +          .assertErrorsWithCodes([ParserErrorCode.EXTERNAL_OPERATOR_WITH_BODY]);
  +    }
  +  }
  +
  +  void test_externalSetterWithBody() {
  +    createParser('external set x(int value) {}');
  +    ClassMember member = parser.parseClassMember('C');
  +    expectNotNullIfNoErrors(member);
  +    if (usingFastaParser) {
  +      // TODO(brianwilkerson) Convert codes to errors when highlighting is fixed.
  +      listener
  +          .assertErrorsWithCodes([ParserErrorCode.EXTERNAL_METHOD_WITH_BODY]);
  +//      listener.assertErrors(
  +//          [expectedError(ParserErrorCode.EXTERNAL_METHOD_WITH_BODY, 26, 2)]);
  +    } else {
  +      listener
  +          .assertErrorsWithCodes([ParserErrorCode.EXTERNAL_SETTER_WITH_BODY]);
  +    }
  +  }
  +
  +  void test_externalTypedef() {
  +    parseCompilationUnit("external typedef F();",
  +        errors: [expectedError(ParserErrorCode.EXTERNAL_TYPEDEF, 0, 8)]);
  +  }
  +
  +  void test_extraCommaInParameterList() {
  +    createParser('(int a, , int b)');
  +    FormalParameterList list = parser.parseFormalParameterList();
  +    expectNotNullIfNoErrors(list);
  +    listener.assertErrors([
  +      expectedError(ParserErrorCode.MISSING_IDENTIFIER, 8, 1),
  +      expectedError(ParserErrorCode.EXPECTED_TOKEN, 8, 1)
  +    ]);
  +  }
  +
  +  void test_extraCommaTrailingNamedParameterGroup() {
  +    createParser('({int b},)');
  +    FormalParameterList list = parser.parseFormalParameterList();
  +    expectNotNullIfNoErrors(list);
  +    listener.assertErrors([
  +      expectedError(ParserErrorCode.MISSING_IDENTIFIER, 9, 1),
  +      expectedError(ParserErrorCode.NORMAL_BEFORE_OPTIONAL_PARAMETERS, 9, 1)
  +    ]);
  +  }
  +
  +  void test_extraCommaTrailingPositionalParameterGroup() {
  +    createParser('([int b],)');
  +    FormalParameterList list = parser.parseFormalParameterList();
  +    expectNotNullIfNoErrors(list);
  +    listener.assertErrors([
  +      expectedError(ParserErrorCode.MISSING_IDENTIFIER, 9, 1),
  +      expectedError(ParserErrorCode.NORMAL_BEFORE_OPTIONAL_PARAMETERS, 9, 1)
  +    ]);
  +  }
  +
  +  void test_extraTrailingCommaInParameterList() {
  +    createParser('(a,,)');
  +    FormalParameterList list = parser.parseFormalParameterList();
  +    expectNotNullIfNoErrors(list);
  +    listener.assertErrors(
  +        [expectedError(ParserErrorCode.MISSING_IDENTIFIER, 3, 1)]);
  +  }
  +
  +  void test_factoryTopLevelDeclaration_class() {
  +    parseCompilationUnit("factory class C {}", errors: [
  +      expectedError(ParserErrorCode.FACTORY_TOP_LEVEL_DECLARATION, 0, 7)
  +    ]);
  +  }
  +
  +  void test_factoryTopLevelDeclaration_enum() {
  +    parseCompilationUnit("factory enum E { v }", errors: [
  +      expectedError(ParserErrorCode.FACTORY_TOP_LEVEL_DECLARATION, 0, 7)
  +    ]);
  +  }
  +
  +  void test_factoryTopLevelDeclaration_typedef() {
  +    parseCompilationUnit("factory typedef F();", errors: [
  +      expectedError(ParserErrorCode.FACTORY_TOP_LEVEL_DECLARATION, 0, 7)
  +    ]);
  +  }
  +
  +  void test_factoryWithInitializers() {
  +    createParser('factory C() : x = 3 {}');
  +    ClassMember member = parser.parseClassMember('C');
  +    expectNotNullIfNoErrors(member);
  +    listener.assertErrors(
  +        [expectedError(ParserErrorCode.FACTORY_WITH_INITIALIZERS, 12, 1)]);
  +  }
  +
  +  void test_factoryWithoutBody() {
  +    createParser('factory C();');
  +    ClassMember member = parser.parseClassMember('C');
  +    expectNotNullIfNoErrors(member);
  +    if (usingFastaParser) {
  +      listener.assertErrors(
  +          [expectedError(ParserErrorCode.MISSING_FUNCTION_BODY, 11, 1)]);
  +    } else {
  +      listener.assertErrorsWithCodes([ParserErrorCode.FACTORY_WITHOUT_BODY]);
  +    }
  +  }
  +
  +  void test_fieldInitializerOutsideConstructor() {
  +    createParser('void m(this.x);');
  +    ClassMember member = parser.parseClassMember('C');
  +    expectNotNullIfNoErrors(member);
  +    listener.assertErrors([
  +      expectedError(ParserErrorCode.FIELD_INITIALIZER_OUTSIDE_CONSTRUCTOR, 7, 6)
  +    ]);
  +  }
  +
     void test_finalAndCovariant() {
       createParser('final covariant f = null;');
       ClassMember member = parser.parseClassMember('C');
       expectNotNullIfNoErrors(member);
  -    listener.assertErrorsWithCodes([ParserErrorCode.FINAL_AND_COVARIANT]);
  +    listener.assertErrors(
  +        [expectedError(ParserErrorCode.FINAL_AND_COVARIANT, 6, 9)]);
     }
   
     void test_finalAndVar() {
       createParser('final var x = null;');
       ClassMember member = parser.parseClassMember('C');
       expectNotNullIfNoErrors(member);
  -    listener.assertErrorsWithCodes([ParserErrorCode.FINAL_AND_VAR]);
  +    listener.assertErrors([expectedError(ParserErrorCode.FINAL_AND_VAR, 6, 3)]);
     }
   
     void test_finalClass() {
       parseCompilationUnit("final class C {}",
  -        codes: [ParserErrorCode.FINAL_CLASS]);
  +        errors: [expectedError(ParserErrorCode.FINAL_CLASS, 0, 5)]);
     }
   
     void test_finalConstructor() {
       createParser('final C() {}');
       ClassMember member = parser.parseClassMember('C');
       expectNotNullIfNoErrors(member);
  -    listener.assertErrorsWithCodes(usingFastaParser
  -        ? [ParserErrorCode.EXTRANEOUS_MODIFIER]
  -        : [ParserErrorCode.FINAL_CONSTRUCTOR]);
  +    if (usingFastaParser) {
  +      listener.assertErrors(
  +          [expectedError(ParserErrorCode.EXTRANEOUS_MODIFIER, 0, 5)]);
  +    } else {
  +      listener.assertErrorsWithCodes([ParserErrorCode.FINAL_CONSTRUCTOR]);
  +    }
     }
   
     void test_finalEnum() {
       parseCompilationUnit("final enum E {ONE}",
  -        codes: [ParserErrorCode.FINAL_ENUM]);
  +        errors: [expectedError(ParserErrorCode.FINAL_ENUM, 0, 5)]);
     }
   
     void test_finalMethod() {
       createParser('final int m() {}');
       ClassMember member = parser.parseClassMember('C');
       expectNotNullIfNoErrors(member);
  -    listener.assertErrorsWithCodes(usingFastaParser
  -        ? [ParserErrorCode.EXTRANEOUS_MODIFIER]
  -        : [ParserErrorCode.FINAL_METHOD]);
  +    if (usingFastaParser) {
  +      listener.assertErrors(
  +          [expectedError(ParserErrorCode.EXTRANEOUS_MODIFIER, 0, 5)]);
  +    } else {
  +      listener.assertErrorsWithCodes([ParserErrorCode.FINAL_METHOD]);
  +    }
     }
   
     void test_finalTypedef() {
       parseCompilationUnit("final typedef F();",
  -        codes: [ParserErrorCode.FINAL_TYPEDEF]);
  +        errors: [expectedError(ParserErrorCode.FINAL_TYPEDEF, 0, 5)]);
     }
   
     void test_functionTypedParameter_const() {
  -    parseCompilationUnit("void f(const x()) {}",
  -        codes: [ParserErrorCode.FUNCTION_TYPED_PARAMETER_VAR]);
  +    parseCompilationUnit("void f(const x()) {}", errors: [
  +      expectedError(ParserErrorCode.FUNCTION_TYPED_PARAMETER_VAR, 7, 9)
  +    ]);
     }
   
     void test_functionTypedParameter_final() {
  -    parseCompilationUnit("void f(final x()) {}",
  -        codes: [ParserErrorCode.FUNCTION_TYPED_PARAMETER_VAR]);
  +    parseCompilationUnit("void f(final x()) {}", errors: [
  +      expectedError(ParserErrorCode.FUNCTION_TYPED_PARAMETER_VAR, 7, 9)
  +    ]);
     }
   
     void test_functionTypedParameter_incomplete1() {
       // This caused an exception at one point.
  -    parseCompilationUnit("void f(int Function(",
  -        codes: fe.Scanner.useFasta
  -            ? [
  -                ScannerErrorCode.EXPECTED_TOKEN,
  -                ScannerErrorCode.EXPECTED_TOKEN,
  -                ParserErrorCode.MISSING_FUNCTION_BODY,
  -                ParserErrorCode.MISSING_IDENTIFIER,
  -              ]
  -            : [
  -                ParserErrorCode.MISSING_FUNCTION_BODY,
  -                ParserErrorCode.MISSING_CLOSING_PARENTHESIS,
  -                ParserErrorCode.EXPECTED_EXECUTABLE,
  -                ParserErrorCode.MISSING_CONST_FINAL_VAR_OR_TYPE,
  -                ParserErrorCode.EXPECTED_TOKEN,
  -                ParserErrorCode.EXPECTED_TOKEN
  -              ]);
  +    if (fe.Scanner.useFasta) {
  +      parseCompilationUnit("void f(int Function(", errors: [
  +        expectedError(ScannerErrorCode.EXPECTED_TOKEN, 20, 0),
  +        expectedError(ScannerErrorCode.EXPECTED_TOKEN, 20, 0),
  +        expectedError(ParserErrorCode.MISSING_FUNCTION_BODY, 20, 0),
  +        expectedError(ParserErrorCode.MISSING_IDENTIFIER, 20, 0),
  +      ]);
  +    } else {
  +      parseCompilationUnit("void f(int Function(", codes: [
  +        ParserErrorCode.MISSING_FUNCTION_BODY,
  +        ParserErrorCode.MISSING_CLOSING_PARENTHESIS,
  +        ParserErrorCode.EXPECTED_EXECUTABLE,
  +        ParserErrorCode.MISSING_CONST_FINAL_VAR_OR_TYPE,
  +        ParserErrorCode.EXPECTED_TOKEN,
  +        ParserErrorCode.EXPECTED_TOKEN
  +      ]);
  +    }
     }
   
     void test_functionTypedParameter_var() {
  -    parseCompilationUnit("void f(var x()) {}",
  -        codes: [ParserErrorCode.FUNCTION_TYPED_PARAMETER_VAR]);
  +    parseCompilationUnit("void f(var x()) {}", errors: [
  +      expectedError(ParserErrorCode.FUNCTION_TYPED_PARAMETER_VAR, 7, 7)
  +    ]);
     }
   
     void test_genericFunctionType_extraLessThan() {
  
positive.code:         [expectedError(ParserErrorCode.COVARIANT_AFTER_VAR, 4, 9)]);
    }
  
    void test_covariantAndStatic() {
      createParser('covariant static A f;');
      ClassMember member = parser.parseClassMember('C');
      expectNotNullIfNoErrors(member);
      listener.assertErrors(
          [expectedError(ParserErrorCode.COVARIANT_AND_STATIC, 10, 6)]);
    }
  
    void test_covariantConstructor() {
      createParser('class C { covariant C(); }');
      ClassDeclaration member = parseFullCompilationUnitMember();
      expectNotNullIfNoErrors(member);
      listener.assertErrors(
          [expectedError(ParserErrorCode.COVARIANT_CONSTRUCTOR, 10, 9)]);
    }
  
    void test_covariantMember_getter_noReturnType() {
      createParser('static covariant get x => 0;');
      ClassMember member = parser.parseClassMember('C');
      expectNotNullIfNoErrors(member);
      listener
          .assertErrors([expectedError(ParserErrorCode.COVARIANT_MEMBER, 7, 9)]);
    }
  
    void test_covariantMember_getter_returnType() {
      createParser('static covariant int get x => 0;');
      ClassMember member = parser.parseClassMember('C');
      expectNotNullIfNoErrors(member);
      listener
          .assertErrors([expectedError(ParserErrorCode.COVARIANT_MEMBER, 7, 9)]);
    }
  
    void test_covariantMember_method() {
      createParser('covariant int m() => 0;');
      ClassMember member = parser.parseClassMember('C');
      expectNotNullIfNoErrors(member);
      listener
          .assertErrors([expectedError(ParserErrorCode.COVARIANT_MEMBER, 0, 9)]);
    }
  
    void test_covariantTopLevelDeclaration_class() {
      createParser('covariant class C {}');
      ClassDeclaration member = parseFullCompilationUnitMember();
      expectNotNullIfNoErrors(member);
      listener.assertErrors(
          [expectedError(ParserErrorCode.COVARIANT_TOP_LEVEL_DECLARATION, 0, 9)]);
    }
  
    void test_covariantTopLevelDeclaration_enum() {
      createParser('covariant enum E { v }');
      EnumDeclaration member = parseFullCompilationUnitMember();
      expectNotNullIfNoErrors(member);
      listener.assertErrors(
          [expectedError(ParserErrorCode.COVARIANT_TOP_LEVEL_DECLARATION, 0, 9)]);
    }
  
    void test_covariantTopLevelDeclaration_typedef() {
      parseCompilationUnit("covariant typedef F();", errors: [
        expectedError(ParserErrorCode.COVARIANT_TOP_LEVEL_DECLARATION, 0, 9)
      ]);
    }
  
    void test_defaultValueInFunctionType_named_colon() {
      createParser('({int x : 0})');
      FormalParameter parameter =
          parser.parseFormalParameterList(inFunctionType: true).parameters[0];
      expectNotNullIfNoErrors(parameter);
      listener.assertErrors(
          [expectedError(ParserErrorCode.DEFAULT_VALUE_IN_FUNCTION_TYPE, 8, 1)]);
    }
  
    void test_defaultValueInFunctionType_named_equal() {
      createParser('({int x = 0})');
      FormalParameter parameter =
          parser.parseFormalParameterList(inFunctionType: true).parameters[0];
      expectNotNullIfNoErrors(parameter);
      listener.assertErrors(
          [expectedError(ParserErrorCode.DEFAULT_VALUE_IN_FUNCTION_TYPE, 8, 1)]);
    }
  
    void test_defaultValueInFunctionType_positional() {
      createParser('([int x = 0])');
      FormalParameter parameter =
          parser.parseFormalParameterList(inFunctionType: true).parameters[0];
      expectNotNullIfNoErrors(parameter);
      listener.assertErrors(
          [expectedError(ParserErrorCode.DEFAULT_VALUE_IN_FUNCTION_TYPE, 8, 1)]);
    }
  
    void test_directiveAfterDeclaration_classBeforeDirective() {
      // TODO(brianwilkerson) Remove codes when highlighting is fixed.
      CompilationUnit unit = parseCompilationUnit("class Foo{} library l;",
          codes: usingFastaParser
              ? [ParserErrorCode.LIBRARY_DIRECTIVE_NOT_FIRST]
              : [ParserErrorCode.DIRECTIVE_AFTER_DECLARATION],
          errors: usingFastaParser
              ? [
                  expectedError(
                      ParserErrorCode.LIBRARY_DIRECTIVE_NOT_FIRST, 12, 10)
                ]
              : [
                  expectedError(
                      ParserErrorCode.DIRECTIVE_AFTER_DECLARATION, 12, 10)
                ]);
      expect(unit, isNotNull);
    }
  
    void test_directiveAfterDeclaration_classBetweenDirectives() {
      // TODO(brianwilkerson) Remove codes when highlighting is fixed.
      CompilationUnit unit =
          parseCompilationUnit("library l;\nclass Foo{}\npart 'a.dart';", codes: [
        ParserErrorCode.DIRECTIVE_AFTER_DECLARATION
      ], errors: [
        expectedError(ParserErrorCode.DIRECTIVE_AFTER_DECLARATION, 23, 14)
      ]);
      expect(unit, isNotNull);
    }
  
    void test_duplicatedModifier_const() {
      createParser('const const m = null;');
      ClassMember member = parser.parseClassMember('C');
      expectNotNullIfNoErrors(member);
      listener.assertErrors(
          [expectedError(ParserErrorCode.DUPLICATED_MODIFIER, 6, 5)]);
    }
  
    void test_duplicatedModifier_external() {
      createParser('external external f();');
      ClassMember member = parser.parseClassMember('C');
      expectNotNullIfNoErrors(member);
      listener.assertErrors(
          [expectedError(ParserErrorCode.DUPLICATED_MODIFIER, 9, 8)]);
    }
  
    void test_duplicatedModifier_factory() {
      createParser('factory factory C() {}');
      ClassMember member = parser.parseClassMember('C');
      expectNotNullIfNoErrors(member);
      listener.assertErrors(
          [expectedError(ParserErrorCode.DUPLICATED_MODIFIER, 8, 7)]);
    }
  
    void test_duplicatedModifier_final() {
      createParser('final final m = null;');
      ClassMember member = parser.parseClassMember('C');
      expectNotNullIfNoErrors(member);
      listener.assertErrors(
          [expectedError(ParserErrorCode.DUPLICATED_MODIFIER, 6, 5)]);
    }
  
    void test_duplicatedModifier_static() {
      createParser('static static var m;');
      ClassMember member = parser.parseClassMember('C');
      expectNotNullIfNoErrors(member);
      listener.assertErrors(
          [expectedError(ParserErrorCode.DUPLICATED_MODIFIER, 7, 6)]);
    }
  
    void test_duplicatedModifier_var() {
      createParser('var var m;');
      ClassMember member = parser.parseClassMember('C');
      expectNotNullIfNoErrors(member);
      listener.assertErrors(
          [expectedError(ParserErrorCode.DUPLICATED_MODIFIER, 4, 3)]);
    }
  
    void test_duplicateLabelInSwitchStatement() {
      SwitchStatement statement =
          parseStatement('switch (e) {l1: case 0: break; l1: case 1: break;}');
      expectNotNullIfNoErrors(statement);
      listener.assertErrors([
        expectedError(ParserErrorCode.DUPLICATE_LABEL_IN_SWITCH_STATEMENT, 31, 2)
      ]);
    }
  
    void test_emptyEnumBody() {
      createParser('enum E {}');
      EnumDeclaration declaration = parseFullCompilationUnitMember();
      expectNotNullIfNoErrors(declaration);
      // TODO(brianwilkerson) Convert codes to errors when highlighting is fixed.
      listener.assertErrorsWithCodes([ParserErrorCode.EMPTY_ENUM_BODY]);
  //    listener
  //        .assertErrors([expectedError(ParserErrorCode.EMPTY_ENUM_BODY, 7, 2),]);
    }
  
    void test_enumInClass() {
      parseCompilationUnit(r'''
  class Foo {
    enum Bar {
      Bar1, Bar2, Bar3
    }
  }
  ''', errors: [expectedError(ParserErrorCode.ENUM_IN_CLASS, 14, 4)]);
    }
  
    void test_equalityCannotBeEqualityOperand_eq_eq() {
      parseExpression("1 == 2 == 3", errors: [
        expectedError(ParserErrorCode.EQUALITY_CANNOT_BE_EQUALITY_OPERAND, 7, 2)
      ]);
    }
  
    void test_equalityCannotBeEqualityOperand_eq_neq() {
      parseExpression("1 == 2 != 3", errors: [
        expectedError(ParserErrorCode.EQUALITY_CANNOT_BE_EQUALITY_OPERAND, 7, 2)
      ]);
    }
  
    void test_equalityCannotBeEqualityOperand_neq_eq() {
      parseExpression("1 != 2 == 3", errors: [
        expectedError(ParserErrorCode.EQUALITY_CANNOT_BE_EQUALITY_OPERAND, 7, 2)
      ]);
    }
  
    void test_expectedCaseOrDefault() {
      SwitchStatement statement = parseStatement('switch (e) {break;}');
      expectNotNullIfNoErrors(statement);
      listener.assertErrors(
          [expectedError(ParserErrorCode.EXPECTED_CASE_OR_DEFAULT, 12, 5)]);
    }
  
    void test_expectedClassMember_inClass_afterType() {
      createParser('heart 2 heart');
      ClassMember member = parser.parseClassMember('C');
      expectNotNullIfNoErrors(member);
      listener.assertErrors(
          [expectedError(ParserErrorCode.EXPECTED_CLASS_MEMBER, 0, 5)]);
    }
  
    void test_expectedClassMember_inClass_beforeType() {
      createParser('4 score');
      ClassMember member = parser.parseClassMember('C');
      expectNotNullIfNoErrors(member);
      listener.assertErrors(
          [expectedError(ParserErrorCode.EXPECTED_CLASS_MEMBER, 0, 1)]);
    }
  
    void test_expectedExecutable_afterAnnotation_atEOF() {
      // TODO(brianwilkerson) Remove codes when highlighting is fixed.
      parseCompilationUnit('@A',
          codes: [ParserErrorCode.EXPECTED_EXECUTABLE],
          errors: [expectedError(ParserErrorCode.EXPECTED_EXECUTABLE, 1, 1)]);
    }
  
    void test_expectedExecutable_inClass_afterVoid() {
      createParser('void 2 void');
      ClassMember member = parser.parseClassMember('C');
      expectNotNullIfNoErrors(member);
      listener.assertErrors(
          [expectedError(ParserErrorCode.EXPECTED_EXECUTABLE, 5, 1)]);
    }
  
    void test_expectedExecutable_topLevel_afterType() {
      createParser('heart 2 heart');
      CompilationUnitMember member = parseFullCompilationUnitMember();
      expectNotNullIfNoErrors(member);
      listener.assertErrors(
          [expectedError(ParserErrorCode.EXPECTED_EXECUTABLE, 0, 5)]);
    }
  
    void test_expectedExecutable_topLevel_afterVoid() {
      createParser('void 2 void');
      CompilationUnitMember member = parseFullCompilationUnitMember();
      expectNotNullIfNoErrors(member);
      listener.assertErrors(
          [expectedError(ParserErrorCode.EXPECTED_EXECUTABLE, 5, 1)]);
    }
  
    void test_expectedExecutable_topLevel_beforeType() {
      createParser('4 score');
      CompilationUnitMember member = parseFullCompilationUnitMember();
      expectNotNullIfNoErrors(member);
      listener.assertErrors(
          [expectedError(ParserErrorCode.EXPECTED_EXECUTABLE, 0, 1)]);
    }
  
    void test_expectedExecutable_topLevel_eof() {
      createParser('x');
      CompilationUnitMember member = parseFullCompilationUnitMember();
      expectNotNullIfNoErrors(member);
      listener.assertErrors(
          [expectedError(ParserErrorCode.EXPECTED_EXECUTABLE, 0, 1)]);
    }
  
    void test_expectedInterpolationIdentifier() {
      StringLiteral literal = parseExpression("'\$x\$'", errors: [
        fe.Scanner.useFasta
            ? expectedError(ScannerErrorCode.MISSING_IDENTIFIER, 3, 1)
            : expectedError(ParserErrorCode.MISSING_IDENTIFIER, 3, 1)
      ]);
      expectNotNullIfNoErrors(literal);
    }
  
    void test_expectedInterpolationIdentifier_emptyString() {
      // The scanner inserts an empty string token between the two $'s; we need to
      // make sure that the MISSING_IDENTIFIER error that is generated has a
      // nonzero width so that it will show up in the editor UI.
      StringLiteral literal = parseExpression("'\$\$foo'",
  //        codes: fe.Scanner.useFasta
  //            ? [ScannerErrorCode.MISSING_IDENTIFIER]
  //            : [ParserErrorCode.MISSING_IDENTIFIER],
          errors: fe.Scanner.useFasta
              ? [expectedError(ScannerErrorCode.MISSING_IDENTIFIER, 2, 1)]
              : [expectedError(ParserErrorCode.MISSING_IDENTIFIER, 2, 1)]);
      expectNotNullIfNoErrors(literal);
    }
  
    @failingTest
    void test_expectedListOrMapLiteral() {
      // It isn't clear that this test can ever pass. The parser is currently
      // create a synthetic list literal in this case, but isSynthetic() isn't
      // overridden for ListLiteral. The problem is that the synthetic list
      // literals that are being created are not always zero length (because they
      // could have type parameters), which violates the contract of
      // isSynthetic().
      TypedLiteral literal = parseListOrMapLiteral(null, '1');
      expectNotNullIfNoErrors(literal);
      listener.assertErrors(
          [expectedError(ParserErrorCode.EXPECTED_LIST_OR_MAP_LITERAL, 1, 1)]);
      expect(literal.isSynthetic, isTrue);
    }
  
    void test_expectedStringLiteral() {
      StringLiteral literal = parseStringLiteral('1');
      expectNotNullIfNoErrors(literal);
      listener.assertErrors(
          [expectedError(ParserErrorCode.EXPECTED_STRING_LITERAL, 0, 1)]);
      expect(literal.isSynthetic, isTrue);
    }
  
    void test_expectedToken_commaMissingInArgumentList() {
      createParser('(x, y z)');
      ArgumentList list = parser.parseArgumentList();
      expectNotNullIfNoErrors(list);
      listener
          .assertErrors([expectedError(ParserErrorCode.EXPECTED_TOKEN, 4, 1)]);
    }
  
    void test_expectedToken_parseStatement_afterVoid() {
      parseStatement("void}");
      listener.assertErrors([
        expectedError(ParserErrorCode.EXPECTED_TOKEN, 4, 1),
        expectedError(ParserErrorCode.MISSING_IDENTIFIER, 4, 1)
      ]);
    }
  
    void test_expectedToken_semicolonMissingAfterExport() {
      // TODO(brianwilkerson) Remove codes when highlighting is fixed.
      CompilationUnit unit = parseCompilationUnit("export '' class A {}",
          codes: [ParserErrorCode.EXPECTED_TOKEN],
          errors: [expectedError(ParserErrorCode.EXPECTED_TOKEN, 7, 2)]);
      ExportDirective directive = unit.directives[0] as ExportDirective;
      expect(directive.uri, isNotNull);
      expect(directive.uri.stringValue, '');
      expect(directive.uri.beginToken.isSynthetic, false);
      expect(directive.uri.isSynthetic, false);
      Token semicolon = directive.semicolon;
      expect(semicolon, isNotNull);
      expect(semicolon.isSynthetic, isTrue);
      ClassDeclaration clazz = unit.declarations[0] as ClassDeclaration;
      expect(clazz.name.name, 'A');
    }
  
    void test_expectedToken_semicolonMissingAfterExpression() {
      parseStatement("x");
      // TODO(brianwilkerson) Convert codes to errors when highlighting is fixed.
      listener.assertErrorsWithCodes([ParserErrorCode.EXPECTED_TOKEN]);
  //    listener
  //        .assertErrors([expectedError(ParserErrorCode.EXPECTED_TOKEN, 0, 1)]);
    }
  
    void test_expectedToken_semicolonMissingAfterImport() {
      // TODO(brianwilkerson) Remove codes when highlighting is fixed.
      CompilationUnit unit = parseCompilationUnit("import '' class A {}",
          codes: [ParserErrorCode.EXPECTED_TOKEN],
          errors: [expectedError(ParserErrorCode.EXPECTED_TOKEN, 7, 2)]);
      ImportDirective directive = unit.directives[0] as ImportDirective;
      Token semicolon = directive.semicolon;
      expect(semicolon, isNotNull);
      expect(semicolon.isSynthetic, isTrue);
    }
  
    void test_expectedToken_uriAndSemicolonMissingAfterExport() {
      CompilationUnit unit = parseCompilationUnit("export class A {}", errors: [
        expectedError(ParserErrorCode.EXPECTED_STRING_LITERAL, 7, 5),
        expectedError(ParserErrorCode.EXPECTED_TOKEN, 7, 5),
      ]);
      ExportDirective directive = unit.directives[0] as ExportDirective;
      expect(directive.uri, isNotNull);
      expect(directive.uri.stringValue, '');
      expect(directive.uri.beginToken.isSynthetic, true);
      expect(directive.uri.isSynthetic, true);
      Token semicolon = directive.semicolon;
      expect(semicolon, isNotNull);
      expect(semicolon.isSynthetic, isTrue);
      ClassDeclaration clazz = unit.declarations[0] as ClassDeclaration;
      expect(clazz.name.name, 'A');
    }
  
    void test_expectedToken_whileMissingInDoStatement() {
      parseStatement("do {} (x);");
      listener
          .assertErrors([expectedError(ParserErrorCode.EXPECTED_TOKEN, 9, 1)]);
    }
  
    void test_expectedTypeName_as() {
      parseExpression("x as",
          errors: [expectedError(ParserErrorCode.EXPECTED_TYPE_NAME, 4, 0)]);
    }
  
    void test_expectedTypeName_as_void() {
      parseExpression("x as void)",
          errors: [expectedError(ParserErrorCode.EXPECTED_TYPE_NAME, 5, 4)]);
    }
  
    void test_expectedTypeName_is() {
      // ###
      parseExpression("x is", codes: [ParserErrorCode.EXPECTED_TYPE_NAME]);
    }
  
    void test_expectedTypeName_is_void() {
      parseExpression("x is void)", codes: [ParserErrorCode.EXPECTED_TYPE_NAME]);
    }
  
    void test_exportDirectiveAfterPartDirective() {
      parseCompilationUnit("part 'a.dart'; export 'b.dart';",
          codes: [ParserErrorCode.EXPORT_DIRECTIVE_AFTER_PART_DIRECTIVE]);
    }
  
    void test_externalAfterConst() {
      createParser('const external C();');
      ClassMember member = parser.parseClassMember('C');
      expectNotNullIfNoErrors(member);
      listener.assertErrorsWithCodes([ParserErrorCode.EXTERNAL_AFTER_CONST]);
    }
  
    void test_externalAfterFactory() {
      createParser('factory external C();');
      ClassMember member = parser.parseClassMember('C');
      expectNotNullIfNoErrors(member);
      listener.assertErrorsWithCodes([ParserErrorCode.EXTERNAL_AFTER_FACTORY]);
    }
  
    void test_externalAfterStatic() {
      createParser('static external int m();');
      ClassMember member = parser.parseClassMember('C');
      expectNotNullIfNoErrors(member);
      listener.assertErrorsWithCodes([ParserErrorCode.EXTERNAL_AFTER_STATIC]);
    }
  
    void test_externalClass() {
      parseCompilationUnit("external class C {}",
          codes: [ParserErrorCode.EXTERNAL_CLASS]);
    }
  
    void test_externalConstructorWithBody_factory() {
      createParser('external factory C() {}');
      ClassMember member = parser.parseClassMember('C');
      expectNotNullIfNoErrors(member);
      listener.assertErrorsWithCodes(
          [ParserErrorCode.EXTERNAL_CONSTRUCTOR_WITH_BODY]);
    }
  
    void test_externalConstructorWithBody_named() {
      createParser('external C.c() {}');
      ClassMember member = parser.parseClassMember('C');
      expectNotNullIfNoErrors(member);
      listener.assertErrorsWithCodes(usingFastaParser
          ? [ParserErrorCode.EXTERNAL_METHOD_WITH_BODY]
          : [ParserErrorCode.EXTERNAL_CONSTRUCTOR_WITH_BODY]);
    }
  
    void test_externalEnum() {
      parseCompilationUnit("external enum E {ONE}",
          codes: [ParserErrorCode.EXTERNAL_ENUM]);
    }
  
    void test_externalField_const() {
      createParser('external const A f;');
      ClassMember member = parser.parseClassMember('C');
      expectNotNullIfNoErrors(member);
      listener.assertErrorsWithCodes(usingFastaParser
          ? [
              ParserErrorCode.EXTERNAL_FIELD,
              CompileTimeErrorCode.CONST_NOT_INITIALIZED
            ]
          : [ParserErrorCode.EXTERNAL_FIELD]);
    }
  
    void test_externalField_final() {
      createParser('external final A f;');
      ClassMember member = parser.parseClassMember('C');
      expectNotNullIfNoErrors(member);
      listener.assertErrorsWithCodes([ParserErrorCode.EXTERNAL_FIELD]);
    }
  
    void test_externalField_static() {
      createParser('external static A f;');
      ClassMember member = parser.parseClassMember('C');
      expectNotNullIfNoErrors(member);
      listener.assertErrorsWithCodes([ParserErrorCode.EXTERNAL_FIELD]);
    }
  
    void test_externalField_typed() {
      createParser('external A f;');
      ClassMember member = parser.parseClassMember('C');
      expectNotNullIfNoErrors(member);
      listener.assertErrorsWithCodes([ParserErrorCode.EXTERNAL_FIELD]);
    }
  
    void test_externalField_untyped() {
      createParser('external var f;');
      ClassMember member = parser.parseClassMember('C');
      expectNotNullIfNoErrors(member);
      listener.assertErrorsWithCodes([ParserErrorCode.EXTERNAL_FIELD]);
    }
  
    void test_externalGetterWithBody() {
      createParser('external int get x {}');
      ClassMember member = parser.parseClassMember('C');
      expectNotNullIfNoErrors(member);
      listener.assertErrorsWithCodes(usingFastaParser
          ? [ParserErrorCode.EXTERNAL_METHOD_WITH_BODY]
          : [ParserErrorCode.EXTERNAL_GETTER_WITH_BODY]);
    }
  
    void test_externalMethodWithBody() {
      createParser('external m() {}');
      ClassMember member = parser.parseClassMember('C');
      expectNotNullIfNoErrors(member);
      listener.assertErrorsWithCodes([ParserErrorCode.EXTERNAL_METHOD_WITH_BODY]);
    }
  
    void test_externalOperatorWithBody() {
      createParser('external operator +(int value) {}');
      ClassMember member = parser.parseClassMember('C');
      expectNotNullIfNoErrors(member);
      listener.assertErrorsWithCodes(usingFastaParser
          ? [ParserErrorCode.EXTERNAL_METHOD_WITH_BODY]
          : [ParserErrorCode.EXTERNAL_OPERATOR_WITH_BODY]);
    }
  
    void test_externalSetterWithBody() {
      createParser('external set x(int value) {}');
      ClassMember member = parser.parseClassMember('C');
      expectNotNullIfNoErrors(member);
      listener.assertErrorsWithCodes(usingFastaParser
          ? [ParserErrorCode.EXTERNAL_METHOD_WITH_BODY]
          : [ParserErrorCode.EXTERNAL_SETTER_WITH_BODY]);
    }
  
    void test_externalTypedef() {
      parseCompilationUnit("external typedef F();",
          codes: [ParserErrorCode.EXTERNAL_TYPEDEF]);
    }
  
    void test_extraCommaInParameterList() {
      createParser('(int a, , int b)');
      FormalParameterList list = parser.parseFormalParameterList();
      expectNotNullIfNoErrors(list);
      listener.assertErrorsWithCodes(
          [ParserErrorCode.MISSING_IDENTIFIER, ParserErrorCode.EXPECTED_TOKEN]);
    }
  
    void test_extraCommaTrailingNamedParameterGroup() {
      createParser('({int b},)');
      FormalParameterList list = parser.parseFormalParameterList();
      expectNotNullIfNoErrors(list);
      listener.assertErrorsWithCodes([
        ParserErrorCode.MISSING_IDENTIFIER,
        ParserErrorCode.NORMAL_BEFORE_OPTIONAL_PARAMETERS
      ]);
    }
  
    void test_extraCommaTrailingPositionalParameterGroup() {
      createParser('([int b],)');
      FormalParameterList list = parser.parseFormalParameterList();
      expectNotNullIfNoErrors(list);
      listener.assertErrorsWithCodes([
        ParserErrorCode.MISSING_IDENTIFIER,
        ParserErrorCode.NORMAL_BEFORE_OPTIONAL_PARAMETERS
      ]);
    }
  
    void test_extraTrailingCommaInParameterList() {
      createParser('(a,,)');
      FormalParameterList list = parser.parseFormalParameterList();
      expectNotNullIfNoErrors(list);
      listener.assertErrorsWithCodes([ParserErrorCode.MISSING_IDENTIFIER]);
    }
  
    void test_factoryTopLevelDeclaration_class() {
      parseCompilationUnit("factory class C {}",
          codes: [ParserErrorCode.FACTORY_TOP_LEVEL_DECLARATION]);
    }
  
    void test_factoryTopLevelDeclaration_enum() {
      parseCompilationUnit("factory enum E { v }",
          codes: [ParserErrorCode.FACTORY_TOP_LEVEL_DECLARATION]);
    }
  
    void test_factoryTopLevelDeclaration_typedef() {
      parseCompilationUnit("factory typedef F();",
          codes: [ParserErrorCode.FACTORY_TOP_LEVEL_DECLARATION]);
    }
  
    void test_factoryWithInitializers() {
      createParser('factory C() : x = 3 {}');
      ClassMember member = parser.parseClassMember('C');
      expectNotNullIfNoErrors(member);
      listener.assertErrorsWithCodes([ParserErrorCode.FACTORY_WITH_INITIALIZERS]);
    }
  
    void test_factoryWithoutBody() {
      createParser('factory C();');
      ClassMember member = parser.parseClassMember('C');
      expectNotNullIfNoErrors(member);
      listener.assertErrorsWithCodes(usingFastaParser
          ? [ParserErrorCode.MISSING_FUNCTION_BODY]
          : [ParserErrorCode.FACTORY_WITHOUT_BODY]);
    }
  
    void test_fieldInitializerOutsideConstructor() {
      createParser('void m(this.x);');
      ClassMember member = parser.parseClassMember('C');
      expectNotNullIfNoErrors(member);
      listener.assertErrorsWithCodes(
          [ParserErrorCode.FIELD_INITIALIZER_OUTSIDE_CONSTRUCTOR]);
    }
  
    void test_covariantAndFinal() {
      createParser('covariant final f = null;');
      ClassMember member = parser.parseClassMember('C');
  
negative.code: }''');
      CompilationUnit unit = parser.parseCompilationUnit2();
      expectNotNullIfNoErrors(unit);
      listener
          .assertErrors([expectedError(ParserErrorCode.UNEXPECTED_TOKEN, 30, 1)]);
    }
  
    void test_getterInFunction_block_noReturnType() {
      FunctionDeclarationStatement statement =
          parseStatement("get x { return _x; }");
      listener.assertErrors(
          [expectedError(ParserErrorCode.GETTER_IN_FUNCTION, 0, 3)]);
      expect(statement.functionDeclaration.functionExpression.parameters, isNull);
    }
  
    void test_getterInFunction_block_returnType() {
      parseStatement("int get x { return _x; }");
      listener.assertErrors(
          [expectedError(ParserErrorCode.GETTER_IN_FUNCTION, 4, 3)]);
    }
  
    void test_getterInFunction_expression_noReturnType() {
      parseStatement("get x => _x;");
      listener.assertErrors(
          [expectedError(ParserErrorCode.GETTER_IN_FUNCTION, 0, 3)]);
    }
  
    void test_getterInFunction_expression_returnType() {
      parseStatement("int get x => _x;");
      listener.assertErrors(
          [expectedError(ParserErrorCode.GETTER_IN_FUNCTION, 4, 3)]);
    }
  
    void test_getterWithParameters() {
      createParser('int get x() {}');
      ClassMember member = parser.parseClassMember('C');
      expectNotNullIfNoErrors(member);
      // TODO(brianwilkerson) Convert codes to errors when highlighting is fixed.
      listener.assertErrorsWithCodes([ParserErrorCode.GETTER_WITH_PARAMETERS]);
  //    listener.assertErrors(
  //        [expectedError(ParserErrorCode.GETTER_WITH_PARAMETERS, 9, 2)]);
    }
  
    void test_illegalAssignmentToNonAssignable_postfix_minusMinus_literal() {
      parseExpression("0--", errors: [
        expectedError(ParserErrorCode.ILLEGAL_ASSIGNMENT_TO_NON_ASSIGNABLE, 1, 2)
      ]);
    }
  
    void test_illegalAssignmentToNonAssignable_postfix_plusPlus_literal() {
      parseExpression("0++", errors: [
        expectedError(ParserErrorCode.ILLEGAL_ASSIGNMENT_TO_NON_ASSIGNABLE, 1, 2)
      ]);
    }
  
    void test_illegalAssignmentToNonAssignable_postfix_plusPlus_parenthesized() {
      parseExpression("(x)++", errors: [
        expectedError(ParserErrorCode.ILLEGAL_ASSIGNMENT_TO_NON_ASSIGNABLE, 3, 2)
      ]);
    }
  
    void test_illegalAssignmentToNonAssignable_primarySelectorPostfix() {
      parseExpression("x(y)(z)++", errors: [
        expectedError(ParserErrorCode.ILLEGAL_ASSIGNMENT_TO_NON_ASSIGNABLE, 7, 2)
      ]);
    }
  
    void test_illegalAssignmentToNonAssignable_superAssigned() {
  