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

Unified Diff: pkg/analyzer/lib/src/generated/parser.dart

Issue 765923003: Partial fix for issue 1934 (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years 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 | « no previous file | pkg/analyzer/test/generated/parser_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/lib/src/generated/parser.dart
diff --git a/pkg/analyzer/lib/src/generated/parser.dart b/pkg/analyzer/lib/src/generated/parser.dart
index 07ef20ea86ca9002c5c292c2b36e0b7aafb2f370..a823e7d2d470ab7c0822f3a1b561d42a2546e2b8 100644
--- a/pkg/analyzer/lib/src/generated/parser.dart
+++ b/pkg/analyzer/lib/src/generated/parser.dart
@@ -6372,7 +6372,7 @@ class Parser {
Expression initialization = null;
if (!_matches(TokenType.SEMICOLON)) {
CommentAndMetadata commentAndMetadata = _parseCommentAndMetadata();
- if (_matchesIdentifier() && _tokenMatchesKeyword(_peek(), Keyword.IN)) {
+ if (_matchesIdentifier() && (_tokenMatchesKeyword(_peek(), Keyword.IN) || _tokenMatches(_peek(), TokenType.COLON))) {
List<VariableDeclaration> variables = new List<VariableDeclaration>();
SimpleIdentifier variableName = parseSimpleIdentifier();
variables.add(
@@ -6389,7 +6389,10 @@ class Parser {
} else {
initialization = parseExpression2();
}
- if (_matchesKeyword(Keyword.IN)) {
+ if (_matchesKeyword(Keyword.IN) || _matches(TokenType.COLON)) {
+ if (_matches(TokenType.COLON)) {
+ _reportErrorForCurrentToken(ParserErrorCode.COLON_IN_PLACE_OF_IN);
+ }
DeclaredIdentifier loopVariable = null;
SimpleIdentifier identifier = null;
if (variableList == null) {
@@ -6426,7 +6429,7 @@ class Parser {
identifier = variable.name;
}
}
- Token inKeyword = _expectKeyword(Keyword.IN);
+ Token inKeyword = andAdvance;
Expression iterator = parseExpression2();
Token rightParenthesis = _expect(TokenType.CLOSE_PAREN);
Statement body = parseStatement2();
@@ -10085,6 +10088,10 @@ class ParserErrorCode extends ErrorCode {
'BREAK_OUTSIDE_OF_LOOP',
"A break statement cannot be used outside of a loop or switch statement");
+ static const ParserErrorCode COLON_IN_PLACE_OF_IN = const ParserErrorCode(
+ 'COLON_IN_PLACE_OF_IN',
+ "For-in loops use 'in' rather than a colon");
+
static const ParserErrorCode CONST_AND_FINAL = const ParserErrorCode(
'CONST_AND_FINAL',
"Members cannot be declared to be both 'const' and 'final'");
« no previous file with comments | « no previous file | pkg/analyzer/test/generated/parser_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698