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

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

Issue 9212018: More parser stuff to handle pseudo keywords as identifiers (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: '' Created 8 years, 11 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 | tests/language/src/PseudoKWTest.dart » ('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 #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 2384 matching lines...) Expand 10 before | Expand all | Expand 10 after
2395 // The type can only be already set in the factory case. 2395 // The type can only be already set in the factory case.
2396 if (!member.has_factory) { 2396 if (!member.has_factory) {
2397 ErrorMsg(member.name_pos, "constructor must not specify return type"); 2397 ErrorMsg(member.name_pos, "constructor must not specify return type");
2398 } 2398 }
2399 } 2399 }
2400 if (CurrentToken() != Token::kLPAREN) { 2400 if (CurrentToken() != Token::kLPAREN) {
2401 ErrorMsg("left parenthesis expected"); 2401 ErrorMsg("left parenthesis expected");
2402 } 2402 }
2403 } else if ((CurrentToken() == Token::kGET) && 2403 } else if ((CurrentToken() == Token::kGET) &&
2404 (LookaheadToken(1) != Token::kLPAREN) && 2404 (LookaheadToken(1) != Token::kLPAREN) &&
2405 !member.has_var && !member.has_final) { 2405 (LookaheadToken(1) != Token::kASSIGN) &&
2406 (LookaheadToken(1) != Token::kCOMMA) &&
2407 (LookaheadToken(1) != Token::kSEMICOLON)) {
2406 ConsumeToken(); 2408 ConsumeToken();
2407 member.kind = RawFunction::kGetterFunction; 2409 member.kind = RawFunction::kGetterFunction;
2408 member.name_pos = this->token_index_; 2410 member.name_pos = this->token_index_;
2409 member.name = ExpectIdentifier("identifier expected"); 2411 member.name = ExpectIdentifier("identifier expected");
2410 // If the result type was not specified, it will be set to DynamicType. 2412 // If the result type was not specified, it will be set to DynamicType.
2411 } else if ((CurrentToken() == Token::kSET) && 2413 } else if ((CurrentToken() == Token::kSET) &&
2412 (LookaheadToken(1) != Token::kLPAREN) && 2414 (LookaheadToken(1) != Token::kLPAREN) &&
2413 !member.has_var && !member.has_final) { 2415 (LookaheadToken(1) != Token::kASSIGN) &&
2416 (LookaheadToken(1) != Token::kCOMMA) &&
2417 (LookaheadToken(1) != Token::kSEMICOLON)) {
2414 ConsumeToken(); 2418 ConsumeToken();
2415 member.kind = RawFunction::kSetterFunction; 2419 member.kind = RawFunction::kSetterFunction;
2416 member.name_pos = this->token_index_; 2420 member.name_pos = this->token_index_;
2417 member.name = ExpectIdentifier("identifier expected"); 2421 member.name = ExpectIdentifier("identifier expected");
2418 // The grammar allows a return type, so member.type is not always NULL here. 2422 // The grammar allows a return type, so member.type is not always NULL here.
2419 // If no return type is specified, the return type of the setter is Dynamic. 2423 // If no return type is specified, the return type of the setter is Dynamic.
2420 if (member.type == NULL) { 2424 if (member.type == NULL) {
2421 member.type = &Type::ZoneHandle(Type::DynamicType()); 2425 member.type = &Type::ZoneHandle(Type::DynamicType());
2422 } 2426 }
2423 } else if ((CurrentToken() == Token::kOPERATOR) && 2427 } else if ((CurrentToken() == Token::kOPERATOR) &&
2424 (LookaheadToken(1) != Token::kLPAREN) && 2428 (LookaheadToken(1) != Token::kLPAREN) &&
2425 !member.has_var && !member.has_final) { 2429 (LookaheadToken(1) != Token::kASSIGN) &&
2430 (LookaheadToken(1) != Token::kCOMMA) &&
2431 (LookaheadToken(1) != Token::kSEMICOLON)) {
2426 ConsumeToken(); 2432 ConsumeToken();
2427 if (!Token::CanBeOverloaded(CurrentToken())) { 2433 if (!Token::CanBeOverloaded(CurrentToken())) {
2428 ErrorMsg("invalid operator overloading"); 2434 ErrorMsg("invalid operator overloading");
2429 } 2435 }
2430 if (member.has_static) { 2436 if (member.has_static) {
2431 ErrorMsg("operator overloading functions cannot be static"); 2437 ErrorMsg("operator overloading functions cannot be static");
2432 } 2438 }
2433 member.kind = RawFunction::kFunction; 2439 member.kind = RawFunction::kFunction;
2434 member.name_pos = this->token_index_; 2440 member.name_pos = this->token_index_;
2435 member.name = 2441 member.name =
(...skipping 5297 matching lines...) Expand 10 before | Expand all | Expand 10 after
7733 } 7739 }
7734 7740
7735 7741
7736 void Parser::SkipNestedExpr() { 7742 void Parser::SkipNestedExpr() {
7737 const bool saved_mode = SetAllowFunctionLiterals(true); 7743 const bool saved_mode = SetAllowFunctionLiterals(true);
7738 SkipExpr(); 7744 SkipExpr();
7739 SetAllowFunctionLiterals(saved_mode); 7745 SetAllowFunctionLiterals(saved_mode);
7740 } 7746 }
7741 7747
7742 } // namespace dart 7748 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | tests/language/src/PseudoKWTest.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698