| 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 part of scanner; | 5 part of scanner; |
| 6 | 6 |
| 7 class FormalParameterType { | 7 class FormalParameterType { |
| 8 final String type; | 8 final String type; |
| 9 const FormalParameterType(this.type); | 9 const FormalParameterType(this.type); |
| 10 bool get isRequired => this == REQUIRED; | 10 bool get isRequired => this == REQUIRED; |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 208 assert(optional('part', token)); | 208 assert(optional('part', token)); |
| 209 assert(optional('of', token.next)); | 209 assert(optional('of', token.next)); |
| 210 Token partKeyword = token; | 210 Token partKeyword = token; |
| 211 token = parseQualified(token.next.next); | 211 token = parseQualified(token.next.next); |
| 212 Token semicolon = token; | 212 Token semicolon = token; |
| 213 token = expect(';', token); | 213 token = expect(';', token); |
| 214 listener.endPartOf(partKeyword, semicolon); | 214 listener.endPartOf(partKeyword, semicolon); |
| 215 return token; | 215 return token; |
| 216 } | 216 } |
| 217 | 217 |
| 218 Token parseMetadataStar(Token token) { | 218 Token parseMetadataStar(Token token, {bool forParameter: false}) { |
| 219 listener.beginMetadataStar(token); |
| 220 int count = 0; |
| 219 while (optional('@', token)) { | 221 while (optional('@', token)) { |
| 220 token = parseMetadata(token); | 222 token = parseMetadata(token); |
| 223 count++; |
| 221 } | 224 } |
| 225 listener.endMetadataStar(count, forParameter); |
| 222 return token; | 226 return token; |
| 223 } | 227 } |
| 224 | 228 |
| 225 /** | 229 /** |
| 226 * Parse | 230 * Parse |
| 227 * [: '@' qualified (‘.’ identifier)? (arguments)? :] | 231 * [: '@' qualified (‘.’ identifier)? (arguments)? :] |
| 228 */ | 232 */ |
| 229 Token parseMetadata(Token token) { | 233 Token parseMetadata(Token token) { |
| 230 listener.beginMetadata(token); | 234 listener.beginMetadata(token); |
| 231 Token atToken = token; | 235 Token atToken = token; |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 319 token = parseOptionalFormalParameters(token, true); | 323 token = parseOptionalFormalParameters(token, true); |
| 320 break; | 324 break; |
| 321 } | 325 } |
| 322 token = parseFormalParameter(token, FormalParameterType.REQUIRED); | 326 token = parseFormalParameter(token, FormalParameterType.REQUIRED); |
| 323 } while (optional(',', token)); | 327 } while (optional(',', token)); |
| 324 listener.endFormalParameters(parameterCount, begin, token); | 328 listener.endFormalParameters(parameterCount, begin, token); |
| 325 return expect(')', token); | 329 return expect(')', token); |
| 326 } | 330 } |
| 327 | 331 |
| 328 Token parseFormalParameter(Token token, FormalParameterType type) { | 332 Token parseFormalParameter(Token token, FormalParameterType type) { |
| 333 token = parseMetadataStar(token, forParameter: true); |
| 329 listener.beginFormalParameter(token); | 334 listener.beginFormalParameter(token); |
| 330 token = parseModifiers(token); | 335 token = parseModifiers(token); |
| 331 // TODO(ahe): Validate that there are formal parameters if void. | 336 // TODO(ahe): Validate that there are formal parameters if void. |
| 332 token = parseReturnTypeOpt(token); | 337 token = parseReturnTypeOpt(token); |
| 333 Token thisKeyword = null; | 338 Token thisKeyword = null; |
| 334 if (optional('this', token)) { | 339 if (optional('this', token)) { |
| 335 thisKeyword = token; | 340 thisKeyword = token; |
| 336 // TODO(ahe): Validate field initializers are only used in | 341 // TODO(ahe): Validate field initializers are only used in |
| 337 // constructors, and not for function-typed arguments. | 342 // constructors, and not for function-typed arguments. |
| 338 token = expect('.', token.next); | 343 token = expect('.', token.next); |
| (...skipping 2087 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2426 } | 2431 } |
| 2427 listener.handleContinueStatement(hasTarget, continueKeyword, token); | 2432 listener.handleContinueStatement(hasTarget, continueKeyword, token); |
| 2428 return expectSemicolon(token); | 2433 return expectSemicolon(token); |
| 2429 } | 2434 } |
| 2430 | 2435 |
| 2431 Token parseEmptyStatement(Token token) { | 2436 Token parseEmptyStatement(Token token) { |
| 2432 listener.handleEmptyStatement(token); | 2437 listener.handleEmptyStatement(token); |
| 2433 return expectSemicolon(token); | 2438 return expectSemicolon(token); |
| 2434 } | 2439 } |
| 2435 } | 2440 } |
| OLD | NEW |