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 '../scanner.dart' show ErrorToken; | 7 import '../scanner.dart' show ErrorToken; |
8 | 8 |
9 import '../scanner/recover.dart' show closeBraceFor, skipToEof; | 9 import '../scanner/recover.dart' show closeBraceFor, skipToEof; |
10 | 10 |
(...skipping 474 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
485 ++parameterCount; | 485 ++parameterCount; |
486 String value = token.stringValue; | 486 String value = token.stringValue; |
487 if (identical(value, '[')) { | 487 if (identical(value, '[')) { |
488 token = parseOptionalFormalParameters(token, false, | 488 token = parseOptionalFormalParameters(token, false, |
489 inFunctionType: inFunctionType); | 489 inFunctionType: inFunctionType); |
490 break; | 490 break; |
491 } else if (identical(value, '{')) { | 491 } else if (identical(value, '{')) { |
492 token = parseOptionalFormalParameters(token, true, | 492 token = parseOptionalFormalParameters(token, true, |
493 inFunctionType: inFunctionType); | 493 inFunctionType: inFunctionType); |
494 break; | 494 break; |
495 } else if (identical(value, '[]')) { | |
496 reportRecoverableError(token, | |
497 ErrorKind.EmptyOptionalParameterList); | |
498 break; | |
499 } | 495 } |
500 token = parseFormalParameter(token, FormalParameterType.REQUIRED, | 496 token = parseFormalParameter(token, FormalParameterType.REQUIRED, |
501 inFunctionType: inFunctionType); | 497 inFunctionType: inFunctionType); |
502 } while (optional(',', token)); | 498 } while (optional(',', token)); |
503 listener.endFormalParameters(parameterCount, begin, token); | 499 listener.endFormalParameters(parameterCount, begin, token); |
504 return expect(')', token); | 500 return expect(')', token); |
505 } | 501 } |
506 | 502 |
507 Token parseFormalParameter(Token token, FormalParameterType kind, | 503 Token parseFormalParameter(Token token, FormalParameterType kind, |
508 {bool inFunctionType: false}) { | 504 {bool inFunctionType: false}) { |
(...skipping 3073 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3582 break; | 3578 break; |
3583 } | 3579 } |
3584 if (isRecoverable) { | 3580 if (isRecoverable) { |
3585 listener.handleRecoverableError(token, kind, arguments); | 3581 listener.handleRecoverableError(token, kind, arguments); |
3586 return null; | 3582 return null; |
3587 } else { | 3583 } else { |
3588 return listener.handleUnrecoverableError(token, kind, arguments)?.next; | 3584 return listener.handleUnrecoverableError(token, kind, arguments)?.next; |
3589 } | 3585 } |
3590 } | 3586 } |
3591 } | 3587 } |
OLD | NEW |