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

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

Issue 3003863002: [kernel] Position on switch expression (Closed)
Patch Set: Created 3 years, 3 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
« no previous file with comments | « pkg/front_end/lib/src/fasta/parser/listener.dart ('k') | pkg/kernel/binary.md » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 '../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 3868 matching lines...) Expand 10 before | Expand all | Expand 10 after
3879 } 3879 }
3880 listener.endTryStatement(catchCount, tryKeyword, finallyKeyword); 3880 listener.endTryStatement(catchCount, tryKeyword, finallyKeyword);
3881 return token; 3881 return token;
3882 } 3882 }
3883 3883
3884 Token parseSwitchStatement(Token token) { 3884 Token parseSwitchStatement(Token token) {
3885 assert(optional('switch', token)); 3885 assert(optional('switch', token));
3886 Token switchKeyword = token; 3886 Token switchKeyword = token;
3887 listener.beginSwitchStatement(switchKeyword); 3887 listener.beginSwitchStatement(switchKeyword);
3888 token = parseParenthesizedExpression(token.next); 3888 token = parseParenthesizedExpression(token.next);
3889 token = parseSwitchBlock(token); 3889 token = parseSwitchBlock(token, switchKeyword);
3890 listener.endSwitchStatement(switchKeyword, token); 3890 listener.endSwitchStatement(switchKeyword, token);
3891 return token.next; 3891 return token.next;
3892 } 3892 }
3893 3893
3894 Token parseSwitchBlock(Token token) { 3894 Token parseSwitchBlock(Token token, Token switchKeyword) {
ahe 2017/08/25 10:04:31 This token is already passed to endSwitchStatement
3895 Token begin = token; 3895 Token begin = token;
3896 listener.beginSwitchBlock(begin); 3896 listener.beginSwitchBlock(begin);
3897 token = expect('{', token); 3897 token = expect('{', token);
3898 int caseCount = 0; 3898 int caseCount = 0;
3899 while (!identical(token.kind, EOF_TOKEN)) { 3899 while (!identical(token.kind, EOF_TOKEN)) {
3900 if (optional('}', token)) { 3900 if (optional('}', token)) {
3901 break; 3901 break;
3902 } 3902 }
3903 token = parseSwitchCase(token); 3903 token = parseSwitchCase(token);
3904 ++caseCount; 3904 ++caseCount;
3905 } 3905 }
3906 listener.endSwitchBlock(caseCount, begin, token); 3906 listener.endSwitchBlock(caseCount, begin, token, switchKeyword);
3907 expect('}', token); 3907 expect('}', token);
3908 return token; 3908 return token;
3909 } 3909 }
3910 3910
3911 /// Peek after the following labels (if any). The following token 3911 /// Peek after the following labels (if any). The following token
3912 /// is used to determine if the labels belong to a statement or a 3912 /// is used to determine if the labels belong to a statement or a
3913 /// switch case. 3913 /// switch case.
3914 Token peekPastLabels(Token token) { 3914 Token peekPastLabels(Token token) {
3915 while (token.isIdentifier && optional(':', token.next)) { 3915 while (token.isIdentifier && optional(':', token.next)) {
3916 token = token.next.next; 3916 token = token.next.next;
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
4137 } 4137 }
4138 4138
4139 Token reportUnexpectedToken(Token token) { 4139 Token reportUnexpectedToken(Token token) {
4140 return reportUnrecoverableErrorWithToken( 4140 return reportUnrecoverableErrorWithToken(
4141 token, fasta.templateUnexpectedToken); 4141 token, fasta.templateUnexpectedToken);
4142 } 4142 }
4143 } 4143 }
4144 4144
4145 // TODO(ahe): Remove when analyzer supports generalized function syntax. 4145 // TODO(ahe): Remove when analyzer supports generalized function syntax.
4146 typedef _MessageWithArgument<T> = Message Function(T); 4146 typedef _MessageWithArgument<T> = Message Function(T);
OLDNEW
« no previous file with comments | « pkg/front_end/lib/src/fasta/parser/listener.dart ('k') | pkg/kernel/binary.md » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698