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

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

Issue 2728773002: Fix parsing [a]sync[*] function body modifiers with Fasta. (Closed)
Patch Set: Use endExpressionFunctionBody() instead of endReturnStatement(). 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 1991 matching lines...) Expand 10 before | Expand all | Expand 10 after
2002 if (!allowAbstract) { 2002 if (!allowAbstract) {
2003 reportRecoverableError(token, ErrorKind.ExpectedBody); 2003 reportRecoverableError(token, ErrorKind.ExpectedBody);
2004 } 2004 }
2005 listener.endFunctionBody(0, null, token); 2005 listener.endFunctionBody(0, null, token);
2006 return token; 2006 return token;
2007 } else if (optional('=>', token)) { 2007 } else if (optional('=>', token)) {
2008 Token begin = token; 2008 Token begin = token;
2009 token = parseExpression(token.next); 2009 token = parseExpression(token.next);
2010 if (!isExpression) { 2010 if (!isExpression) {
2011 expectSemicolon(token); 2011 expectSemicolon(token);
2012 listener.endReturnStatement(true, begin, token); 2012 listener.endExpressionFunctionBody(begin, token);
2013 } else { 2013 } else {
2014 listener.endReturnStatement(true, begin, null); 2014 listener.endExpressionFunctionBody(begin, null);
2015 } 2015 }
2016 return token; 2016 return token;
2017 } else if (optional('=', token)) { 2017 } else if (optional('=', token)) {
2018 Token begin = token; 2018 Token begin = token;
2019 // Recover from a bad factory method. 2019 // Recover from a bad factory method.
2020 reportRecoverableError(token, ErrorKind.ExpectedBody); 2020 reportRecoverableError(token, ErrorKind.ExpectedBody);
2021 token = parseExpression(token.next); 2021 token = parseExpression(token.next);
2022 if (!isExpression) { 2022 if (!isExpression) {
2023 expectSemicolon(token); 2023 expectSemicolon(token);
2024 listener.endReturnStatement(true, begin, token); 2024 listener.endExpressionFunctionBody(begin, token);
2025 } else { 2025 } else {
2026 listener.endReturnStatement(true, begin, null); 2026 listener.endExpressionFunctionBody(begin, null);
2027 } 2027 }
2028 return token; 2028 return token;
2029 } 2029 }
2030 Token begin = token; 2030 Token begin = token;
2031 int statementCount = 0; 2031 int statementCount = 0;
2032 if (!optional('{', token)) { 2032 if (!optional('{', token)) {
2033 token = reportUnrecoverableError(token, ErrorKind.ExpectedFunctionBody); 2033 token = reportUnrecoverableError(token, ErrorKind.ExpectedFunctionBody);
2034 listener.handleInvalidFunctionBody(token); 2034 listener.handleInvalidFunctionBody(token);
2035 return token; 2035 return token;
2036 } 2036 }
(...skipping 1508 matching lines...) Expand 10 before | Expand all | Expand 10 after
3545 break; 3545 break;
3546 } 3546 }
3547 if (isRecoverable) { 3547 if (isRecoverable) {
3548 listener.handleRecoverableError(token, kind, arguments); 3548 listener.handleRecoverableError(token, kind, arguments);
3549 return null; 3549 return null;
3550 } else { 3550 } else {
3551 return listener.handleUnrecoverableError(token, kind, arguments); 3551 return listener.handleUnrecoverableError(token, kind, arguments);
3552 } 3552 }
3553 } 3553 }
3554 } 3554 }
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