Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 "lib/invocation_mirror.h" | 7 #include "lib/invocation_mirror.h" |
| 8 #include "platform/utils.h" | 8 #include "platform/utils.h" |
| 9 #include "vm/bootstrap.h" | 9 #include "vm/bootstrap.h" |
| 10 #include "vm/class_finalizer.h" | 10 #include "vm/class_finalizer.h" |
| (...skipping 3040 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3051 | 3051 |
| 3052 void Parser::SkipIf(Token::Kind token) { | 3052 void Parser::SkipIf(Token::Kind token) { |
| 3053 if (CurrentToken() == token) { | 3053 if (CurrentToken() == token) { |
| 3054 ConsumeToken(); | 3054 ConsumeToken(); |
| 3055 } | 3055 } |
| 3056 } | 3056 } |
| 3057 | 3057 |
| 3058 | 3058 |
| 3059 // Skips tokens up to matching closing parenthesis. | 3059 // Skips tokens up to matching closing parenthesis. |
| 3060 void Parser::SkipToMatchingParenthesis() { | 3060 void Parser::SkipToMatchingParenthesis() { |
| 3061 ASSERT(CurrentToken() == Token::kLPAREN); | 3061 Token::Kind current_token = CurrentToken(); |
| 3062 ASSERT(current_token == Token::kLPAREN); | |
| 3062 int level = 0; | 3063 int level = 0; |
| 3063 do { | 3064 do { |
| 3064 if (CurrentToken() == Token::kLPAREN) { | 3065 if (current_token == Token::kLPAREN) { |
| 3065 level++; | 3066 level++; |
| 3066 } else if (CurrentToken() == Token::kRPAREN) { | 3067 } else if (current_token == Token::kRPAREN) { |
| 3067 level--; | 3068 level--; |
| 3068 } | 3069 } |
| 3069 ConsumeToken(); | 3070 ConsumeToken(); |
| 3070 } while ((level > 0) && (CurrentToken() != Token::kEOS)); | 3071 current_token = CurrentToken(); |
| 3072 } while ((level > 0) && (current_token != Token::kEOS)); | |
| 3071 } | 3073 } |
| 3072 | 3074 |
| 3073 | 3075 |
| 3074 void Parser::SkipInitializers() { | 3076 void Parser::SkipInitializers() { |
| 3075 ASSERT(CurrentToken() == Token::kCOLON); | 3077 ASSERT(CurrentToken() == Token::kCOLON); |
| 3076 do { | 3078 do { |
| 3077 ConsumeToken(); // Colon or comma. | 3079 ConsumeToken(); // Colon or comma. |
| 3078 if (CurrentToken() == Token::kSUPER) { | 3080 if (CurrentToken() == Token::kSUPER) { |
| 3079 ConsumeToken(); | 3081 ConsumeToken(); |
| 3080 if (CurrentToken() == Token::kPERIOD) { | 3082 if (CurrentToken() == Token::kPERIOD) { |
| (...skipping 4244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 7325 if (LookaheadToken(1) == Token::kCOLON) { | 7327 if (LookaheadToken(1) == Token::kCOLON) { |
| 7326 // Statement starts with a label. | 7328 // Statement starts with a label. |
| 7327 label_name = CurrentLiteral(); | 7329 label_name = CurrentLiteral(); |
| 7328 label_pos = TokenPos(); | 7330 label_pos = TokenPos(); |
| 7329 ASSERT(label_pos > 0); | 7331 ASSERT(label_pos > 0); |
| 7330 ConsumeToken(); // Consume identifier. | 7332 ConsumeToken(); // Consume identifier. |
| 7331 ConsumeToken(); // Consume colon. | 7333 ConsumeToken(); // Consume colon. |
| 7332 } | 7334 } |
| 7333 } | 7335 } |
| 7334 const intptr_t statement_pos = TokenPos(); | 7336 const intptr_t statement_pos = TokenPos(); |
| 7337 const Token::Kind token = CurrentToken(); | |
| 7335 | 7338 |
| 7336 if (CurrentToken() == Token::kWHILE) { | 7339 if (token == Token::kWHILE) { |
| 7337 statement = ParseWhileStatement(label_name); | 7340 statement = ParseWhileStatement(label_name); |
| 7338 } else if (CurrentToken() == Token::kFOR) { | 7341 } else if (token == Token::kFOR) { |
| 7339 statement = ParseForStatement(label_name); | 7342 statement = ParseForStatement(label_name); |
| 7340 } else if (CurrentToken() == Token::kDO) { | 7343 } else if (token == Token::kDO) { |
| 7341 statement = ParseDoWhileStatement(label_name); | 7344 statement = ParseDoWhileStatement(label_name); |
| 7342 } else if (CurrentToken() == Token::kSWITCH) { | 7345 } else if (token == Token::kSWITCH) { |
| 7343 statement = ParseSwitchStatement(label_name); | 7346 statement = ParseSwitchStatement(label_name); |
| 7344 } else if (CurrentToken() == Token::kTRY) { | 7347 } else if (token == Token::kTRY) { |
| 7345 statement = ParseTryStatement(label_name); | 7348 statement = ParseTryStatement(label_name); |
| 7346 } else if (CurrentToken() == Token::kRETURN) { | 7349 } else if (token == Token::kRETURN) { |
| 7347 const intptr_t return_pos = TokenPos(); | 7350 const intptr_t return_pos = TokenPos(); |
| 7348 ConsumeToken(); | 7351 ConsumeToken(); |
| 7349 if (CurrentToken() != Token::kSEMICOLON) { | 7352 if (CurrentToken() != Token::kSEMICOLON) { |
| 7350 if (current_function().IsConstructor() && | 7353 if (current_function().IsConstructor() && |
| 7351 (current_block_->scope->function_level() == 0)) { | 7354 (current_block_->scope->function_level() == 0)) { |
| 7352 ErrorMsg(return_pos, "return of a value not allowed in constructors"); | 7355 ErrorMsg(return_pos, "return of a value not allowed in constructors"); |
| 7353 } | 7356 } |
| 7354 AstNode* expr = ParseExpr(kAllowConst, kConsumeCascades); | 7357 AstNode* expr = ParseExpr(kAllowConst, kConsumeCascades); |
| 7355 statement = new(isolate()) ReturnNode(statement_pos, expr); | 7358 statement = new(isolate()) ReturnNode(statement_pos, expr); |
| 7356 } else { | 7359 } else { |
| 7357 statement = new(isolate()) ReturnNode(statement_pos); | 7360 statement = new(isolate()) ReturnNode(statement_pos); |
| 7358 } | 7361 } |
| 7359 AddNodeForFinallyInlining(statement); | 7362 AddNodeForFinallyInlining(statement); |
| 7360 ExpectSemicolon(); | 7363 ExpectSemicolon(); |
| 7361 } else if (CurrentToken() == Token::kIF) { | 7364 } else if (token == Token::kIF) { |
| 7362 statement = ParseIfStatement(label_name); | 7365 statement = ParseIfStatement(label_name); |
| 7363 } else if (CurrentToken() == Token::kASSERT) { | 7366 } else if (token == Token::kASSERT) { |
| 7364 statement = ParseAssertStatement(); | 7367 statement = ParseAssertStatement(); |
| 7365 ExpectSemicolon(); | 7368 ExpectSemicolon(); |
| 7366 } else if (IsVariableDeclaration()) { | 7369 } else if (IsVariableDeclaration()) { |
| 7367 statement = ParseVariableDeclarationList(); | 7370 statement = ParseVariableDeclarationList(); |
| 7368 ExpectSemicolon(); | 7371 ExpectSemicolon(); |
| 7369 } else if (IsFunctionDeclaration()) { | 7372 } else if (IsFunctionDeclaration()) { |
| 7370 statement = ParseFunctionStatement(false); | 7373 statement = ParseFunctionStatement(false); |
| 7371 } else if (CurrentToken() == Token::kLBRACE) { | 7374 } else if (token == Token::kLBRACE) { |
| 7372 SourceLabel* label = NULL; | 7375 SourceLabel* label = NULL; |
| 7373 OpenBlock(); | 7376 OpenBlock(); |
| 7374 if (label_name != NULL) { | 7377 if (label_name != NULL) { |
| 7375 label = SourceLabel::New(label_pos, label_name, SourceLabel::kStatement); | 7378 label = SourceLabel::New(label_pos, label_name, SourceLabel::kStatement); |
| 7376 current_block_->scope->AddLabel(label); | 7379 current_block_->scope->AddLabel(label); |
| 7377 } | 7380 } |
| 7378 ConsumeToken(); | 7381 ConsumeToken(); |
| 7379 ParseStatementSequence(); | 7382 ParseStatementSequence(); |
| 7380 statement = CloseBlock(); | 7383 statement = CloseBlock(); |
| 7381 if (label != NULL) { | 7384 if (label != NULL) { |
| 7382 statement->AsSequenceNode()->set_label(label); | 7385 statement->AsSequenceNode()->set_label(label); |
| 7383 } | 7386 } |
| 7384 ExpectToken(Token::kRBRACE); | 7387 ExpectToken(Token::kRBRACE); |
| 7385 } else if (CurrentToken() == Token::kBREAK) { | 7388 } else if (token == Token::kBREAK) { |
| 7386 statement = ParseJump(label_name); | 7389 statement = ParseJump(label_name); |
| 7387 AddNodeForFinallyInlining(statement); | 7390 AddNodeForFinallyInlining(statement); |
| 7388 ExpectSemicolon(); | 7391 ExpectSemicolon(); |
| 7389 } else if (CurrentToken() == Token::kCONTINUE) { | 7392 } else if (token == Token::kCONTINUE) { |
| 7390 statement = ParseJump(label_name); | 7393 statement = ParseJump(label_name); |
| 7391 AddNodeForFinallyInlining(statement); | 7394 AddNodeForFinallyInlining(statement); |
| 7392 ExpectSemicolon(); | 7395 ExpectSemicolon(); |
| 7393 } else if (CurrentToken() == Token::kSEMICOLON) { | 7396 } else if (token == Token::kSEMICOLON) { |
| 7394 // Empty statement, nothing to do. | 7397 // Empty statement, nothing to do. |
| 7395 ConsumeToken(); | 7398 ConsumeToken(); |
| 7396 } else if (CurrentToken() == Token::kRETHROW) { | 7399 } else if (token == Token::kRETHROW) { |
| 7397 // Rethrow of current exception. | 7400 // Rethrow of current exception. |
| 7398 ConsumeToken(); | 7401 ConsumeToken(); |
| 7399 ExpectSemicolon(); | 7402 ExpectSemicolon(); |
| 7400 // Check if it is ok to do a rethrow. | 7403 // Check if it is ok to do a rethrow. |
| 7401 if ((try_blocks_list_ == NULL) || !try_blocks_list_->inside_catch()) { | 7404 if ((try_blocks_list_ == NULL) || !try_blocks_list_->inside_catch()) { |
| 7402 ErrorMsg(statement_pos, "rethrow of an exception is not valid here"); | 7405 ErrorMsg(statement_pos, "rethrow of an exception is not valid here"); |
| 7403 } | 7406 } |
| 7404 // The exception and stack trace variables are bound in the block | 7407 // The exception and stack trace variables are bound in the block |
| 7405 // containing the try. | 7408 // containing the try. |
| 7406 LocalScope* scope = try_blocks_list_->try_block()->scope->parent(); | 7409 LocalScope* scope = try_blocks_list_->try_block()->scope->parent(); |
| (...skipping 3065 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 10472 primary = new(isolate()) StringInterpolateNode(TokenPos(), values); | 10475 primary = new(isolate()) StringInterpolateNode(TokenPos(), values); |
| 10473 } | 10476 } |
| 10474 return primary; | 10477 return primary; |
| 10475 } | 10478 } |
| 10476 | 10479 |
| 10477 | 10480 |
| 10478 AstNode* Parser::ParsePrimary() { | 10481 AstNode* Parser::ParsePrimary() { |
| 10479 TRACE_PARSER("ParsePrimary"); | 10482 TRACE_PARSER("ParsePrimary"); |
| 10480 ASSERT(!is_top_level_); | 10483 ASSERT(!is_top_level_); |
| 10481 AstNode* primary = NULL; | 10484 AstNode* primary = NULL; |
| 10485 const Token::Kind token = CurrentToken(); | |
| 10482 if (IsFunctionLiteral()) { | 10486 if (IsFunctionLiteral()) { |
| 10483 // The name of a literal function is visible from inside the function, but | 10487 // The name of a literal function is visible from inside the function, but |
| 10484 // must not collide with names in the scope declaring the literal. | 10488 // must not collide with names in the scope declaring the literal. |
| 10485 OpenBlock(); | 10489 OpenBlock(); |
| 10486 primary = ParseFunctionStatement(true); | 10490 primary = ParseFunctionStatement(true); |
| 10487 CloseBlock(); | 10491 CloseBlock(); |
| 10488 } else if (IsIdentifier()) { | 10492 } else if (IsIdentifier()) { |
| 10489 QualIdent qual_ident; | 10493 QualIdent qual_ident; |
| 10490 intptr_t qual_ident_pos = TokenPos(); | 10494 intptr_t qual_ident_pos = TokenPos(); |
| 10491 ParseQualIdent(&qual_ident); | 10495 ParseQualIdent(&qual_ident); |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 10551 current_class(), | 10555 current_class(), |
| 10552 qualified_name, | 10556 qualified_name, |
| 10553 NULL, // No arguments. | 10557 NULL, // No arguments. |
| 10554 InvocationMirror::kTopLevel, | 10558 InvocationMirror::kTopLevel, |
| 10555 call_type, | 10559 call_type, |
| 10556 NULL); // No existing function. | 10560 NULL); // No existing function. |
| 10557 } | 10561 } |
| 10558 } | 10562 } |
| 10559 } | 10563 } |
| 10560 ASSERT(primary != NULL); | 10564 ASSERT(primary != NULL); |
| 10561 } else if (CurrentToken() == Token::kTHIS) { | 10565 } else if (token == Token::kTHIS) { |
| 10562 LocalVariable* local = LookupLocalScope(Symbols::This()); | 10566 LocalVariable* local = LookupLocalScope(Symbols::This()); |
| 10563 if (local == NULL) { | 10567 if (local == NULL) { |
| 10564 ErrorMsg("receiver 'this' is not in scope"); | 10568 ErrorMsg("receiver 'this' is not in scope"); |
| 10565 } | 10569 } |
| 10566 primary = new(isolate()) LoadLocalNode(TokenPos(), local); | 10570 primary = new(isolate()) LoadLocalNode(TokenPos(), local); |
| 10567 ConsumeToken(); | 10571 ConsumeToken(); |
| 10568 } else if (CurrentToken() == Token::kINTEGER) { | 10572 } else if (token == Token::kINTEGER) { |
| 10569 const Integer& literal = Integer::ZoneHandle(I, CurrentIntegerLiteral()); | 10573 const Integer& literal = Integer::ZoneHandle(I, CurrentIntegerLiteral()); |
| 10570 primary = new(isolate()) LiteralNode(TokenPos(), literal); | 10574 primary = new(isolate()) LiteralNode(TokenPos(), literal); |
| 10571 ConsumeToken(); | 10575 ConsumeToken(); |
| 10572 } else if (CurrentToken() == Token::kTRUE) { | 10576 } else if (token == Token::kTRUE) { |
| 10573 primary = new(isolate()) LiteralNode(TokenPos(), Bool::True()); | 10577 primary = new(isolate()) LiteralNode(TokenPos(), Bool::True()); |
| 10574 ConsumeToken(); | 10578 ConsumeToken(); |
| 10575 } else if (CurrentToken() == Token::kFALSE) { | 10579 } else if (token == Token::kFALSE) { |
| 10576 primary = new(isolate()) LiteralNode(TokenPos(), Bool::False()); | 10580 primary = new(isolate()) LiteralNode(TokenPos(), Bool::False()); |
| 10577 ConsumeToken(); | 10581 ConsumeToken(); |
| 10578 } else if (CurrentToken() == Token::kNULL) { | 10582 } else if (token == Token::kNULL) { |
| 10579 primary = new(isolate()) LiteralNode(TokenPos(), Instance::ZoneHandle(I)); | 10583 primary = new(isolate()) LiteralNode(TokenPos(), Instance::ZoneHandle(I)); |
| 10580 ConsumeToken(); | 10584 ConsumeToken(); |
| 10581 } else if (CurrentToken() == Token::kLPAREN) { | 10585 } else if (token == Token::kLPAREN) { |
| 10582 ConsumeToken(); | 10586 ConsumeToken(); |
| 10583 const bool saved_mode = SetAllowFunctionLiterals(true); | 10587 const bool saved_mode = SetAllowFunctionLiterals(true); |
| 10584 primary = ParseExpr(kAllowConst, kConsumeCascades); | 10588 primary = ParseExpr(kAllowConst, kConsumeCascades); |
| 10585 SetAllowFunctionLiterals(saved_mode); | 10589 SetAllowFunctionLiterals(saved_mode); |
| 10586 ExpectToken(Token::kRPAREN); | 10590 ExpectToken(Token::kRPAREN); |
| 10587 } else if (CurrentToken() == Token::kDOUBLE) { | 10591 } else if (token == Token::kDOUBLE) { |
| 10588 Double& double_value = Double::ZoneHandle(I, CurrentDoubleLiteral()); | 10592 Double& double_value = Double::ZoneHandle(I, CurrentDoubleLiteral()); |
| 10589 if (double_value.IsNull()) { | 10593 if (double_value.IsNull()) { |
| 10590 ErrorMsg("invalid double literal"); | 10594 ErrorMsg("invalid double literal"); |
| 10591 } | 10595 } |
| 10592 primary = new(isolate()) LiteralNode(TokenPos(), double_value); | 10596 primary = new(isolate()) LiteralNode(TokenPos(), double_value); |
| 10593 ConsumeToken(); | 10597 ConsumeToken(); |
| 10594 } else if (CurrentToken() == Token::kSTRING) { | 10598 } else if (token == Token::kSTRING) { |
| 10595 primary = ParseStringLiteral(true); | 10599 primary = ParseStringLiteral(true); |
| 10596 } else if (CurrentToken() == Token::kNEW) { | 10600 } else if (token == Token::kNEW) { |
| 10597 ConsumeToken(); | 10601 ConsumeToken(); |
| 10598 primary = ParseNewOperator(Token::kNEW); | 10602 primary = ParseNewOperator(Token::kNEW); |
| 10599 } else if (CurrentToken() == Token::kCONST) { | 10603 } else if (token == Token::kCONST) { |
| 10600 if ((LookaheadToken(1) == Token::kLT) || | 10604 if ((LookaheadToken(1) == Token::kLT) || |
| 10601 (LookaheadToken(1) == Token::kLBRACK) || | 10605 (LookaheadToken(1) == Token::kLBRACK) || |
| 10602 (LookaheadToken(1) == Token::kINDEX) || | 10606 (LookaheadToken(1) == Token::kINDEX) || |
| 10603 (LookaheadToken(1) == Token::kLBRACE)) { | 10607 (LookaheadToken(1) == Token::kLBRACE)) { |
| 10604 primary = ParseCompoundLiteral(); | 10608 primary = ParseCompoundLiteral(); |
| 10605 } else { | 10609 } else { |
| 10606 ConsumeToken(); | 10610 ConsumeToken(); |
| 10607 primary = ParseNewOperator(Token::kCONST); | 10611 primary = ParseNewOperator(Token::kCONST); |
| 10608 } | 10612 } |
| 10609 } else if (CurrentToken() == Token::kLT || | 10613 } else if (token == Token::kLT || |
| 10610 CurrentToken() == Token::kLBRACK || | 10614 token == Token::kLBRACK || |
| 10611 CurrentToken() == Token::kINDEX || | 10615 token == Token::kINDEX || |
| 10612 CurrentToken() == Token::kLBRACE) { | 10616 token == Token::kLBRACE) { |
| 10613 primary = ParseCompoundLiteral(); | 10617 primary = ParseCompoundLiteral(); |
| 10614 } else if (CurrentToken() == Token::kHASH) { | 10618 } else if (token == Token::kHASH) { |
| 10615 primary = ParseSymbolLiteral(); | 10619 primary = ParseSymbolLiteral(); |
| 10616 } else if (CurrentToken() == Token::kSUPER) { | 10620 } else if (token == Token::kSUPER) { |
| 10617 if (parsing_metadata_) { | 10621 if (parsing_metadata_) { |
| 10618 ErrorMsg("cannot access superclass from metadata"); | 10622 ErrorMsg("cannot access superclass from metadata"); |
| 10619 } | 10623 } |
| 10620 if (current_function().is_static()) { | 10624 if (current_function().is_static()) { |
| 10621 ErrorMsg("cannot access superclass from static method"); | 10625 ErrorMsg("cannot access superclass from static method"); |
| 10622 } | 10626 } |
| 10623 if (current_class().SuperClass() == Class::null()) { | 10627 if (current_class().SuperClass() == Class::null()) { |
| 10624 ErrorMsg("class '%s' does not have a superclass", | 10628 ErrorMsg("class '%s' does not have a superclass", |
| 10625 String::Handle(isolate(), current_class().Name()).ToCString()); | 10629 String::Handle(isolate(), current_class().Name()).ToCString()); |
| 10626 } | 10630 } |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 10719 SkipExpr(); | 10723 SkipExpr(); |
| 10720 } | 10724 } |
| 10721 } | 10725 } |
| 10722 | 10726 |
| 10723 | 10727 |
| 10724 // Skips function/method/constructor/getter/setter preambles until the formal | 10728 // Skips function/method/constructor/getter/setter preambles until the formal |
| 10725 // parameter list. It is enough to skip the tokens, since we have already | 10729 // parameter list. It is enough to skip the tokens, since we have already |
| 10726 // previously parsed the function. | 10730 // previously parsed the function. |
| 10727 void Parser::SkipFunctionPreamble() { | 10731 void Parser::SkipFunctionPreamble() { |
| 10728 while (true) { | 10732 while (true) { |
| 10729 if (CurrentToken() == Token::kLPAREN || | 10733 const Token::Kind token = CurrentToken(); |
| 10730 CurrentToken() == Token::kARROW || | 10734 if (token == Token::kLPAREN || |
| 10731 CurrentToken() == Token::kSEMICOLON || | 10735 token == Token::kARROW || |
| 10732 CurrentToken() == Token::kLBRACE) { | 10736 token == Token::kSEMICOLON || |
| 10737 token == Token::kLBRACE) { | |
|
srdjan
2014/05/28 02:25:13
Add parentheses here and below.
| |
| 10733 return; | 10738 return; |
| 10734 } | 10739 } |
| 10735 // Case handles "native" keyword, but also return types of form | 10740 // Case handles "native" keyword, but also return types of form |
| 10736 // native.SomeType where native is the name of a library. | 10741 // native.SomeType where native is the name of a library. |
| 10737 if (CurrentToken() == Token::kIDENT && | 10742 if (token == Token::kIDENT && LookaheadToken(1) != Token::kPERIOD) { |
| 10738 LookaheadToken(1) != Token::kPERIOD) { | |
| 10739 if (CurrentLiteral()->raw() == Symbols::Native().raw()) { | 10743 if (CurrentLiteral()->raw() == Symbols::Native().raw()) { |
| 10740 return; | 10744 return; |
| 10741 } | 10745 } |
| 10742 } | 10746 } |
| 10743 ConsumeToken(); | 10747 ConsumeToken(); |
| 10744 } | 10748 } |
| 10745 } | 10749 } |
| 10746 | 10750 |
| 10747 | 10751 |
| 10748 void Parser::SkipListLiteral() { | 10752 void Parser::SkipListLiteral() { |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 10915 UnexpectedToken(); | 10919 UnexpectedToken(); |
| 10916 UNREACHABLE(); | 10920 UNREACHABLE(); |
| 10917 } | 10921 } |
| 10918 break; | 10922 break; |
| 10919 } | 10923 } |
| 10920 } | 10924 } |
| 10921 | 10925 |
| 10922 | 10926 |
| 10923 void Parser::SkipSelectors() { | 10927 void Parser::SkipSelectors() { |
| 10924 while (true) { | 10928 while (true) { |
| 10925 if (CurrentToken() == Token::kCASCADE) { | 10929 const Token::Kind current_token = CurrentToken(); |
| 10930 if (current_token == Token::kCASCADE) { | |
| 10926 ConsumeToken(); | 10931 ConsumeToken(); |
| 10927 if (CurrentToken() == Token::kLBRACK) { | 10932 if (CurrentToken() == Token::kLBRACK) { |
| 10928 continue; // Consume [ in next loop iteration. | 10933 continue; // Consume [ in next loop iteration. |
| 10929 } else { | 10934 } else { |
| 10930 ExpectIdentifier("identifier or [ expected after .."); | 10935 ExpectIdentifier("identifier or [ expected after .."); |
| 10931 } | 10936 } |
| 10932 } else if (CurrentToken() == Token::kPERIOD) { | 10937 } else if (current_token == Token::kPERIOD) { |
| 10933 ConsumeToken(); | 10938 ConsumeToken(); |
| 10934 ExpectIdentifier("identifier expected"); | 10939 ExpectIdentifier("identifier expected"); |
| 10935 } else if (CurrentToken() == Token::kLBRACK) { | 10940 } else if (current_token == Token::kLBRACK) { |
| 10936 ConsumeToken(); | 10941 ConsumeToken(); |
| 10937 SkipNestedExpr(); | 10942 SkipNestedExpr(); |
| 10938 ExpectToken(Token::kRBRACK); | 10943 ExpectToken(Token::kRBRACK); |
| 10939 } else if (CurrentToken() == Token::kLPAREN) { | 10944 } else if (current_token == Token::kLPAREN) { |
| 10940 SkipActualParameters(); | 10945 SkipActualParameters(); |
| 10941 } else { | 10946 } else { |
| 10942 break; | 10947 break; |
| 10943 } | 10948 } |
| 10944 } | 10949 } |
| 10945 } | 10950 } |
| 10946 | 10951 |
| 10947 void Parser::SkipPostfixExpr() { | 10952 void Parser::SkipPostfixExpr() { |
| 10948 SkipPrimary(); | 10953 SkipPrimary(); |
| 10949 SkipSelectors(); | 10954 SkipSelectors(); |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 11023 void Parser::SkipQualIdent() { | 11028 void Parser::SkipQualIdent() { |
| 11024 ASSERT(IsIdentifier()); | 11029 ASSERT(IsIdentifier()); |
| 11025 ConsumeToken(); | 11030 ConsumeToken(); |
| 11026 if (CurrentToken() == Token::kPERIOD) { | 11031 if (CurrentToken() == Token::kPERIOD) { |
| 11027 ConsumeToken(); // Consume the kPERIOD token. | 11032 ConsumeToken(); // Consume the kPERIOD token. |
| 11028 ExpectIdentifier("identifier expected after '.'"); | 11033 ExpectIdentifier("identifier expected after '.'"); |
| 11029 } | 11034 } |
| 11030 } | 11035 } |
| 11031 | 11036 |
| 11032 } // namespace dart | 11037 } // namespace dart |
| OLD | NEW |