Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(116)

Side by Side Diff: pkg/front_end/lib/src/fasta/parser/parser.dart

Issue 3004683002: report abstract as extraneous modifier (Closed)
Patch Set: Created 3 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « pkg/analyzer/test/generated/parser_fasta_test.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 2041 matching lines...) Expand 10 before | Expand all | Expand 10 after
2052 if (token.type.isBuiltIn) { 2052 if (token.type.isBuiltIn) {
2053 // A built-in identifier can only be a modifier as long as it is 2053 // A built-in identifier can only be a modifier as long as it is
2054 // followed by another modifier or an identifier. Otherwise, it is the 2054 // followed by another modifier or an identifier. Otherwise, it is the
2055 // identifier. 2055 // identifier.
2056 if (token.next.kind != KEYWORD_TOKEN && !token.next.isIdentifier) { 2056 if (token.next.kind != KEYWORD_TOKEN && !token.next.isIdentifier) {
2057 break; 2057 break;
2058 } 2058 }
2059 } 2059 }
2060 int order = modifierOrder(token); 2060 int order = modifierOrder(token);
2061 if (order < 3) { 2061 if (order < 3) {
2062 // `abstract` isn't parsed with this method.
2063 if (order > currentOrder) { 2062 if (order > currentOrder) {
2064 currentOrder = order; 2063 currentOrder = order;
2065 if (optional("var", token)) { 2064 if (optional("var", token)) {
2066 if (!isVarAllowed && parameterKind == null) { 2065 if (!isVarAllowed && parameterKind == null) {
2067 reportRecoverableErrorWithToken( 2066 reportRecoverableErrorWithToken(
2068 token, fasta.templateExtraneousModifier); 2067 token, fasta.templateExtraneousModifier);
2069 } 2068 }
2070 switch (typeContinuation ?? TypeContinuation.Required) { 2069 switch (typeContinuation ?? TypeContinuation.Required) {
2071 case TypeContinuation.NormalFormalParameter: 2070 case TypeContinuation.NormalFormalParameter:
2072 typeContinuation = 2071 typeContinuation =
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
2142 continue; 2141 continue;
2143 } 2142 }
2144 } 2143 }
2145 token = parseModifier(token); 2144 token = parseModifier(token);
2146 count++; 2145 count++;
2147 } else { 2146 } else {
2148 reportRecoverableErrorWithToken( 2147 reportRecoverableErrorWithToken(
2149 token, fasta.templateExtraneousModifier); 2148 token, fasta.templateExtraneousModifier);
2150 token = token.next; 2149 token = token.next;
2151 } 2150 }
2151 } else if (order == 3) {
2152 // abstract
ahe 2017/08/28 11:14:08 Consider this instead of the comment: assert(opti
danrubel 2017/08/29 14:58:47 Good idea. Done.
2153 reportRecoverableErrorWithToken(
2154 token, fasta.templateExtraneousModifier);
ahe 2017/08/28 11:14:08 Should this be a new error code so it's easier to
danrubel 2017/08/29 14:58:47 I need to create a separate error code to distingu
2155 token = token.next;
2152 } else { 2156 } else {
2153 break; 2157 break;
2154 } 2158 }
2155 } 2159 }
2156 listener.handleModifiers(count); 2160 listener.handleModifiers(count);
2157 2161
2158 typeContinuation ??= 2162 typeContinuation ??=
2159 (isVarAllowed || memberKind == MemberKind.GeneralizedFunctionType) 2163 (isVarAllowed || memberKind == MemberKind.GeneralizedFunctionType)
2160 ? TypeContinuation.Required 2164 ? TypeContinuation.Required
2161 : TypeContinuation.Optional; 2165 : TypeContinuation.Optional;
(...skipping 1975 matching lines...) Expand 10 before | Expand all | Expand 10 after
4137 } 4141 }
4138 4142
4139 Token reportUnexpectedToken(Token token) { 4143 Token reportUnexpectedToken(Token token) {
4140 return reportUnrecoverableErrorWithToken( 4144 return reportUnrecoverableErrorWithToken(
4141 token, fasta.templateUnexpectedToken); 4145 token, fasta.templateUnexpectedToken);
4142 } 4146 }
4143 } 4147 }
4144 4148
4145 // TODO(ahe): Remove when analyzer supports generalized function syntax. 4149 // TODO(ahe): Remove when analyzer supports generalized function syntax.
4146 typedef _MessageWithArgument<T> = Message Function(T); 4150 typedef _MessageWithArgument<T> = Message Function(T);
OLDNEW
« no previous file with comments | « pkg/analyzer/test/generated/parser_fasta_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698