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

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

Issue 2742233002: Fix for parsing EmptyFunctionBody with Fasta. (Closed)
Patch Set: Created 3 years, 9 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 '../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 2006 matching lines...) Expand 10 before | Expand all | Expand 10 after
2017 listener.handleFunctionBodySkipped(token); 2017 listener.handleFunctionBodySkipped(token);
2018 } 2018 }
2019 return token; 2019 return token;
2020 } 2020 }
2021 2021
2022 Token parseFunctionBody(Token token, bool isExpression, bool allowAbstract) { 2022 Token parseFunctionBody(Token token, bool isExpression, bool allowAbstract) {
2023 if (optional(';', token)) { 2023 if (optional(';', token)) {
2024 if (!allowAbstract) { 2024 if (!allowAbstract) {
2025 reportRecoverableError(token, ErrorKind.ExpectedBody); 2025 reportRecoverableError(token, ErrorKind.ExpectedBody);
2026 } 2026 }
2027 listener.endFunctionBody(0, null, token); 2027 listener.endEmptyFunctionBody(token);
2028 return token; 2028 return token;
2029 } else if (optional('=>', token)) { 2029 } else if (optional('=>', token)) {
2030 Token begin = token; 2030 Token begin = token;
2031 token = parseExpression(token.next); 2031 token = parseExpression(token.next);
2032 if (!isExpression) { 2032 if (!isExpression) {
2033 expectSemicolon(token); 2033 expectSemicolon(token);
2034 listener.endExpressionFunctionBody(begin, token); 2034 listener.endExpressionFunctionBody(begin, token);
2035 } else { 2035 } else {
2036 listener.endExpressionFunctionBody(begin, null); 2036 listener.endExpressionFunctionBody(begin, null);
2037 } 2037 }
(...skipping 1540 matching lines...) Expand 10 before | Expand all | Expand 10 after
3578 break; 3578 break;
3579 } 3579 }
3580 if (isRecoverable) { 3580 if (isRecoverable) {
3581 listener.handleRecoverableError(token, kind, arguments); 3581 listener.handleRecoverableError(token, kind, arguments);
3582 return null; 3582 return null;
3583 } else { 3583 } else {
3584 return listener.handleUnrecoverableError(token, kind, arguments)?.next; 3584 return listener.handleUnrecoverableError(token, kind, arguments)?.next;
3585 } 3585 }
3586 } 3586 }
3587 } 3587 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698