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

Side by Side Diff: runtime/vm/parser.cc

Issue 11027036: Better error message for const loop variables (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 2 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | 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 #include "vm/parser.h" 5 #include "vm/parser.h"
6 6
7 #include "vm/bigint_operations.h" 7 #include "vm/bigint_operations.h"
8 #include "vm/class_finalizer.h" 8 #include "vm/class_finalizer.h"
9 #include "vm/compiler.h" 9 #include "vm/compiler.h"
10 #include "vm/compiler_stats.h" 10 #include "vm/compiler_stats.h"
(...skipping 5250 matching lines...) Expand 10 before | Expand all | Expand 10 after
5261 return is_function_literal; 5261 return is_function_literal;
5262 } 5262 }
5263 5263
5264 5264
5265 // Current token position is the token after the opening ( of the for 5265 // Current token position is the token after the opening ( of the for
5266 // statement. Returns true if we recognize a for ( .. in expr) 5266 // statement. Returns true if we recognize a for ( .. in expr)
5267 // statement. 5267 // statement.
5268 bool Parser::IsForInStatement() { 5268 bool Parser::IsForInStatement() {
5269 const intptr_t saved_pos = TokenPos(); 5269 const intptr_t saved_pos = TokenPos();
5270 bool result = false; 5270 bool result = false;
5271 if (CurrentToken() == Token::kVAR || CurrentToken() == Token::kFINAL) { 5271 // Allow const modifier as well when recognizing a for-in statement
5272 // pattern. We will get an error later if the loop variable is
5273 // declared with const.
5274 if (CurrentToken() == Token::kVAR ||
5275 CurrentToken() == Token::kFINAL ||
5276 CurrentToken() == Token::kCONST) {
5272 ConsumeToken(); 5277 ConsumeToken();
5273 } 5278 }
5274 if (IsIdentifier()) { 5279 if (IsIdentifier()) {
5275 if (LookaheadToken(1) == Token::kIN) { 5280 if (LookaheadToken(1) == Token::kIN) {
5276 result = true; 5281 result = true;
5277 } else if (TryParseOptionalType()) { 5282 } else if (TryParseOptionalType()) {
5278 if (IsIdentifier()) { 5283 if (IsIdentifier()) {
5279 ConsumeToken(); 5284 ConsumeToken();
5280 } 5285 }
5281 result = (CurrentToken() == Token::kIN); 5286 result = (CurrentToken() == Token::kIN);
(...skipping 4413 matching lines...) Expand 10 before | Expand all | Expand 10 after
9695 void Parser::SkipQualIdent() { 9700 void Parser::SkipQualIdent() {
9696 ASSERT(IsIdentifier()); 9701 ASSERT(IsIdentifier());
9697 ConsumeToken(); 9702 ConsumeToken();
9698 if (CurrentToken() == Token::kPERIOD) { 9703 if (CurrentToken() == Token::kPERIOD) {
9699 ConsumeToken(); // Consume the kPERIOD token. 9704 ConsumeToken(); // Consume the kPERIOD token.
9700 ExpectIdentifier("identifier expected after '.'"); 9705 ExpectIdentifier("identifier expected after '.'");
9701 } 9706 }
9702 } 9707 }
9703 9708
9704 } // namespace dart 9709 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698