| 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 '../fasta_codes.dart' show Code, Message, Template; | 7 import '../fasta_codes.dart' show Code, Message, Template; |
| 8 | 8 |
| 9 import '../fasta_codes.dart' as fasta; | 9 import '../fasta_codes.dart' as fasta; |
| 10 | 10 |
| (...skipping 839 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 850 } | 850 } |
| 851 Token implementsKeyword; | 851 Token implementsKeyword; |
| 852 int interfacesCount = 0; | 852 int interfacesCount = 0; |
| 853 if (optional('implements', token)) { | 853 if (optional('implements', token)) { |
| 854 implementsKeyword = token; | 854 implementsKeyword = token; |
| 855 do { | 855 do { |
| 856 token = parseType(token.next); | 856 token = parseType(token.next); |
| 857 ++interfacesCount; | 857 ++interfacesCount; |
| 858 } while (optional(',', token)); | 858 } while (optional(',', token)); |
| 859 } | 859 } |
| 860 Token nativeToken; |
| 861 if (optional('native', token)) { |
| 862 nativeToken = token; |
| 863 token = parseNativeClause(nativeToken); |
| 864 } |
| 860 token = parseClassBody(token); | 865 token = parseClassBody(token); |
| 861 listener.endClassDeclaration(interfacesCount, begin, classKeyword, | 866 listener.endClassDeclaration(interfacesCount, begin, classKeyword, |
| 862 extendsKeyword, implementsKeyword, token); | 867 extendsKeyword, implementsKeyword, nativeToken, token); |
| 863 return token.next; | 868 return token.next; |
| 864 } | 869 } |
| 865 | 870 |
| 866 Token parseStringPart(Token token) { | 871 Token parseStringPart(Token token) { |
| 867 if (token.kind != STRING_TOKEN) { | 872 if (token.kind != STRING_TOKEN) { |
| 868 token = | 873 token = |
| 869 reportUnrecoverableErrorWithToken(token, fasta.templateExpectedString) | 874 reportUnrecoverableErrorWithToken(token, fasta.templateExpectedString) |
| 870 .next; | 875 .next; |
| 871 } | 876 } |
| 872 listener.handleStringPart(token); | 877 listener.handleStringPart(token); |
| (...skipping 1225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2098 | 2103 |
| 2099 typeContinuation ??= | 2104 typeContinuation ??= |
| 2100 (isVarAllowed || memberKind == MemberKind.GeneralizedFunctionType) | 2105 (isVarAllowed || memberKind == MemberKind.GeneralizedFunctionType) |
| 2101 ? TypeContinuation.Required | 2106 ? TypeContinuation.Required |
| 2102 : TypeContinuation.Optional; | 2107 : TypeContinuation.Optional; |
| 2103 | 2108 |
| 2104 token = parseType(token, typeContinuation, null, memberKind); | 2109 token = parseType(token, typeContinuation, null, memberKind); |
| 2105 return token; | 2110 return token; |
| 2106 } | 2111 } |
| 2107 | 2112 |
| 2113 Token parseNativeClause(Token nativeToken) { |
| 2114 Token token = nativeToken.next; |
| 2115 bool hasName = false; |
| 2116 if (token.kind == STRING_TOKEN) { |
| 2117 hasName = true; |
| 2118 token = parseLiteralString(token); |
| 2119 } |
| 2120 listener.handleNativeClause(nativeToken, hasName); |
| 2121 reportRecoverableError( |
| 2122 nativeToken, fasta.messageNativeClauseShouldBeAnnotation); |
| 2123 return token; |
| 2124 } |
| 2125 |
| 2108 Token skipClassBody(Token token) { | 2126 Token skipClassBody(Token token) { |
| 2109 if (!optional('{', token)) { | 2127 if (!optional('{', token)) { |
| 2110 return reportUnrecoverableErrorWithToken( | 2128 return reportUnrecoverableErrorWithToken( |
| 2111 token, fasta.templateExpectedClassBodyToSkip) | 2129 token, fasta.templateExpectedClassBodyToSkip) |
| 2112 .next; | 2130 .next; |
| 2113 } | 2131 } |
| 2114 Token closeBrace = closeBraceTokenFor(token); | 2132 Token closeBrace = closeBraceTokenFor(token); |
| 2115 if (closeBrace == null || | 2133 if (closeBrace == null || |
| 2116 !identical(closeBrace.kind, $CLOSE_CURLY_BRACKET)) { | 2134 !identical(closeBrace.kind, $CLOSE_CURLY_BRACKET)) { |
| 2117 return reportUnmatchedToken(token).next; | 2135 return reportUnmatchedToken(token).next; |
| (...skipping 1947 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4065 } | 4083 } |
| 4066 | 4084 |
| 4067 Token reportUnexpectedToken(Token token) { | 4085 Token reportUnexpectedToken(Token token) { |
| 4068 return reportUnrecoverableErrorWithToken( | 4086 return reportUnrecoverableErrorWithToken( |
| 4069 token, fasta.templateUnexpectedToken); | 4087 token, fasta.templateUnexpectedToken); |
| 4070 } | 4088 } |
| 4071 } | 4089 } |
| 4072 | 4090 |
| 4073 // TODO(ahe): Remove when analyzer supports generalized function syntax. | 4091 // TODO(ahe): Remove when analyzer supports generalized function syntax. |
| 4074 typedef _MessageWithArgument<T> = Message Function(T); | 4092 typedef _MessageWithArgument<T> = Message Function(T); |
| OLD | NEW |