| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 fasta.parser.parser; | 5 library fasta.parser.parser; |
| 6 | 6 |
| 7 import '../scanner.dart' show ErrorToken; | 7 import '../scanner.dart' show ErrorToken; |
| 8 | 8 |
| 9 import '../scanner/recover.dart' show closeBraceFor, skipToEof; | 9 import '../scanner/recover.dart' show closeBraceFor, skipToEof; |
| 10 | 10 |
| (...skipping 869 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 880 token = reportUnrecoverableError(token, ErrorKind.ExpectedString)?.next; | 880 token = reportUnrecoverableError(token, ErrorKind.ExpectedString)?.next; |
| 881 } | 881 } |
| 882 listener.handleStringPart(token); | 882 listener.handleStringPart(token); |
| 883 return token.next; | 883 return token.next; |
| 884 } | 884 } |
| 885 | 885 |
| 886 Token parseIdentifier(Token token, IdentifierContext context) { | 886 Token parseIdentifier(Token token, IdentifierContext context) { |
| 887 if (!token.isIdentifier()) { | 887 if (!token.isIdentifier()) { |
| 888 token = | 888 token = |
| 889 reportUnrecoverableError(token, ErrorKind.ExpectedIdentifier)?.next; | 889 reportUnrecoverableError(token, ErrorKind.ExpectedIdentifier)?.next; |
| 890 } else if (token.isBuiltInIdentifier) { |
| 891 // It is a compile-time error if a built-in identifier is used as the |
| 892 // declared name of a prefix, class, type parameter or type alias. |
| 893 // It is a compile-time error to use a built-in identifier other than |
| 894 // dynamic as a type annotation or type parameter. |
| 895 switch (context) { |
| 896 case IdentifierContext.importPrefixDeclaration: |
| 897 case IdentifierContext.typedefDeclaration: |
| 898 case IdentifierContext.enumDeclaration: |
| 899 case IdentifierContext.namedMixinDeclaration: |
| 900 case IdentifierContext.classDeclaration: |
| 901 case IdentifierContext.typeVariableDeclaration: |
| 902 reportRecoverableError( |
| 903 token, ErrorKind.BuiltInIdentifierInDeclaration); |
| 904 break; |
| 905 |
| 906 case IdentifierContext.typeReference: |
| 907 case IdentifierContext.typeReferenceContinuation: |
| 908 if (!optional("dynamic", token)) { |
| 909 reportRecoverableError(token, ErrorKind.BuiltInIdentifierAsType); |
| 910 } |
| 911 break; |
| 912 |
| 913 default: |
| 914 break; |
| 915 } |
| 890 } | 916 } |
| 891 listener.handleIdentifier(token, context); | 917 listener.handleIdentifier(token, context); |
| 892 return token.next; | 918 return token.next; |
| 893 } | 919 } |
| 894 | 920 |
| 895 Token expect(String string, Token token) { | 921 Token expect(String string, Token token) { |
| 896 if (!identical(string, token.stringValue)) { | 922 if (!identical(string, token.stringValue)) { |
| 897 return reportUnrecoverableError( | 923 return reportUnrecoverableError( |
| 898 token, ErrorKind.ExpectedButGot, {"expected": string})?.next; | 924 token, ErrorKind.ExpectedButGot, {"expected": string})?.next; |
| 899 } | 925 } |
| (...skipping 2698 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3598 break; | 3624 break; |
| 3599 } | 3625 } |
| 3600 if (isRecoverable) { | 3626 if (isRecoverable) { |
| 3601 listener.handleRecoverableError(token, kind, arguments); | 3627 listener.handleRecoverableError(token, kind, arguments); |
| 3602 return null; | 3628 return null; |
| 3603 } else { | 3629 } else { |
| 3604 return listener.handleUnrecoverableError(token, kind, arguments); | 3630 return listener.handleUnrecoverableError(token, kind, arguments); |
| 3605 } | 3631 } |
| 3606 } | 3632 } |
| 3607 } | 3633 } |
| OLD | NEW |