Chromium Code Reviews| 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 2388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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 Loading... | |
| 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); |
| OLD | NEW |