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

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

Issue 10392024: Add a "Label" Node around an Identifier that is being used as a label. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Only use Label nodes for label introductions. Include the colon. 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
Index: lib/compiler/implementation/scanner/parser.dart
diff --git a/lib/compiler/implementation/scanner/parser.dart b/lib/compiler/implementation/scanner/parser.dart
index becfbf8c7f7e9c461c275fc0f7d0c862906f41c6..c24ed64610a41cc6d9f619825bef173ec89626dd 100644
--- a/lib/compiler/implementation/scanner/parser.dart
+++ b/lib/compiler/implementation/scanner/parser.dart
@@ -842,13 +842,19 @@ class Parser {
return parseExpressionStatement(token);
}
- Token parseLabeledStatement(Token token) {
- listener.beginLabeledStatement(token);
+ Token parseLabel(Token token) {
token = parseIdentifier(token);
Token colon = token;
token = expect(':', token);
+ listener.handleLabel(colon);
+ return token;
+ }
+
+ Token parseLabeledStatement(Token token) {
+ listener.beginLabeledStatement(token);
+ token = parseLabel(token);
token = parseStatement(token);
- listener.endLabeledStatement(colon);
+ listener.endLabeledStatement();
return token;
}
@@ -1571,8 +1577,7 @@ class Parser {
// First an optional label.
if (isIdentifier(token)) {
label = token;
- token = parseIdentifier(token);
- token = expect(':', token);
+ token = parseLabel(token);
}
// Then one or more case expressions, the last of which may be
// 'default' instead.

Powered by Google App Engine
This is Rietveld 408576698