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

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

Issue 3003263002: add support for native methods in class
Patch Set: update listeners Created 3 years, 4 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
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 2388 matching lines...) Expand 10 before | Expand all | Expand 10 after
2399 isGetter = optional("get", getOrSet); 2399 isGetter = optional("get", getOrSet);
2400 listener.handleNoTypeVariables(token); 2400 listener.handleNoTypeVariables(token);
2401 } 2401 }
2402 checkFormals(isGetter, name, token); 2402 checkFormals(isGetter, name, token);
2403 token = parseFormalParametersOpt( 2403 token = parseFormalParametersOpt(
2404 token, 2404 token,
2405 staticModifier != null 2405 staticModifier != null
2406 ? MemberKind.StaticMethod 2406 ? MemberKind.StaticMethod
2407 : MemberKind.NonStaticMethod); 2407 : MemberKind.NonStaticMethod);
2408 token = parseInitializersOpt(token); 2408 token = parseInitializersOpt(token);
2409
2410 Token nativeToken;
2411 if (optional('native', token)) {
2412 nativeToken = token;
2413 token = parseNativeClause(nativeToken);
ahe 2017/08/25 09:05:40 I think the problem is how functions bodies are be
2414 }
2415
2409 AsyncModifier savedAsyncModifier = asyncState; 2416 AsyncModifier savedAsyncModifier = asyncState;
2410 Token asyncToken = token; 2417 Token asyncToken = token;
2411 token = parseAsyncModifier(token); 2418 token = parseAsyncModifier(token);
2412 if (getOrSet != null && !inPlainSync && optional("set", getOrSet)) { 2419 if (getOrSet != null && !inPlainSync && optional("set", getOrSet)) {
2413 reportRecoverableError(asyncToken, fasta.messageSetterNotSync); 2420 reportRecoverableError(asyncToken, fasta.messageSetterNotSync);
2414 } 2421 }
2415 if (optional('=', token)) { 2422 if (optional('=', token)) {
2416 token = parseRedirectingFactoryBody(token); 2423 token = parseRedirectingFactoryBody(token);
2417 } else { 2424 } else {
2418 token = parseFunctionBody( 2425 token = parseFunctionBody(
2419 token, false, staticModifier == null || externalModifier != null); 2426 token,
2427 false,
2428 staticModifier == null ||
2429 externalModifier != null ||
2430 nativeToken != null);
2420 } 2431 }
2421 asyncState = savedAsyncModifier; 2432 asyncState = savedAsyncModifier;
2422 listener.endMethod(getOrSet, start, token); 2433 listener.endMethod(getOrSet, start, nativeToken, token);
2423 return token.next; 2434 return token.next;
2424 } 2435 }
2425 2436
2426 Token parseFactoryMethod(Token token) { 2437 Token parseFactoryMethod(Token token) {
2427 assert(isFactoryDeclaration(token)); 2438 assert(isFactoryDeclaration(token));
2428 Token start = token; 2439 Token start = token;
2429 bool isExternal = false; 2440 bool isExternal = false;
2430 int modifierCount = 0; 2441 int modifierCount = 0;
2431 while (isModifier(token)) { 2442 while (isModifier(token)) {
2432 if (optional('external', token)) { 2443 if (optional('external', token)) {
(...skipping 1704 matching lines...) Expand 10 before | Expand all | Expand 10 after
4137 } 4148 }
4138 4149
4139 Token reportUnexpectedToken(Token token) { 4150 Token reportUnexpectedToken(Token token) {
4140 return reportUnrecoverableErrorWithToken( 4151 return reportUnrecoverableErrorWithToken(
4141 token, fasta.templateUnexpectedToken); 4152 token, fasta.templateUnexpectedToken);
4142 } 4153 }
4143 } 4154 }
4144 4155
4145 // TODO(ahe): Remove when analyzer supports generalized function syntax. 4156 // TODO(ahe): Remove when analyzer supports generalized function syntax.
4146 typedef _MessageWithArgument<T> = Message Function(T); 4157 typedef _MessageWithArgument<T> = Message Function(T);
OLDNEW
« no previous file with comments | « pkg/front_end/lib/src/fasta/parser/listener.dart ('k') | pkg/front_end/lib/src/fasta/source/diet_listener.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698