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

Unified Diff: lib/compiler/implementation/scanner/listener.dart

Issue 10387080: Accept more labels per switch case. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address review comments. Created 8 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « lib/compiler/implementation/resolver.dart ('k') | lib/compiler/implementation/scanner/parser.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/compiler/implementation/scanner/listener.dart
diff --git a/lib/compiler/implementation/scanner/listener.dart b/lib/compiler/implementation/scanner/listener.dart
index 74dd30f0dc1b51b65e5489840bdb8bc7bd995db5..ce4e271072c8ba01694bbf589921f86911bbb678 100644
--- a/lib/compiler/implementation/scanner/listener.dart
+++ b/lib/compiler/implementation/scanner/listener.dart
@@ -165,10 +165,10 @@ class Listener {
void handleLabel(Token token) {
}
- void beginLabeledStatement(Token token) {
+ void beginLabeledStatement(Token token, int labelCount) {
}
- void endLabeledStatement() {
+ void endLabeledStatement(int labelCount) {
}
void beginLiteralMapEntry(Token token) {
@@ -251,6 +251,9 @@ class Listener {
void beginTryStatement(Token token) {
}
+ void handleCaseMatch(Token caseKeyword, Token colon) {
+ }
+
void handleCatchBlock(Token catchKeyword) {
}
@@ -404,7 +407,7 @@ class Listener {
void handleSuperExpression(Token token) {
}
- void handleSwitchCase(Token labelToken, int expressionCount,
+ void handleSwitchCase(int labelCount, int expressionCount,
Token defaultKeyword, int statementCount,
Token firstToken, Token endToken) {
}
@@ -1331,6 +1334,10 @@ class NodeListener extends ElementListener {
tryKeyword, finallyKeyword));
}
+ void handleCaseMatch(Token caseKeyword, Token colon) {
+ pushNode(new CaseMatch(caseKeyword, popNode(), colon));
+ }
+
void handleCatchBlock(Token catchKeyword) {
Block block = popNode();
NodeList formals = popNode();
@@ -1353,16 +1360,13 @@ class NodeListener extends ElementListener {
pushNode(new NodeList(beginToken, caseNodes, endToken, null));
}
- void handleSwitchCase(Token labelToken, int expressionCount,
+ void handleSwitchCase(int labelCount, int caseCount,
Token defaultKeyword, int statementCount,
Token firstToken, Token endToken) {
NodeList statements = makeNodeList(statementCount, null, null, null);
- NodeList expressions = makeNodeList(expressionCount, null, null, null);
- Label label = null;
- if (labelToken !== null) {
- label = popNode();
- }
- pushNode(new SwitchCase(label, expressions, defaultKeyword, statements,
+ NodeList labelsAndCases =
+ makeNodeList(labelCount + caseCount, null, null, null);
+ pushNode(new SwitchCase(labelsAndCases, defaultKeyword, statements,
firstToken));
}
@@ -1439,10 +1443,14 @@ class NodeListener extends ElementListener {
pushNode(new Label(name, colon));
}
- void endLabeledStatement() {
+ void endLabeledStatement(int labelCount) {
Statement statement = popNode();
- Label label = popNode();
- pushNode(new LabeledStatement(label, statement));
+ while (labelCount > 0) {
+ Label label = popNode();
+ statement = new LabeledStatement(label, statement);
+ labelCount--;
+ }
+ pushNode(statement);
}
void log(message) {
« no previous file with comments | « lib/compiler/implementation/resolver.dart ('k') | lib/compiler/implementation/scanner/parser.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698