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

Side by Side Diff: pkg/compiler/lib/src/parser/parser.dart

Issue 2644533002: Mostly use entities in use.dart (Closed)
Patch Set: Fixes Created 3 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
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 library dart2js.parser; 5 library dart2js.parser;
6 6
7 import '../common.dart'; 7 import '../common.dart';
8 import '../tokens/keyword.dart' show Keyword; 8 import '../tokens/keyword.dart' show Keyword;
9 import '../tokens/precedence.dart' show PrecedenceInfo; 9 import '../tokens/precedence.dart' show PrecedenceInfo;
10 import '../tokens/precedence_constants.dart' 10 import '../tokens/precedence_constants.dart'
(...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after
417 expect('(', token); 417 expect('(', token);
418 int parameterCount = 0; 418 int parameterCount = 0;
419 do { 419 do {
420 token = token.next; 420 token = token.next;
421 if (optional(')', token)) { 421 if (optional(')', token)) {
422 break; 422 break;
423 } 423 }
424 ++parameterCount; 424 ++parameterCount;
425 String value = token.stringValue; 425 String value = token.stringValue;
426 if (identical(value, '[')) { 426 if (identical(value, '[')) {
427 token = parseOptionalFormalParameters( 427 token = parseOptionalFormalParameters(token, false,
428 token, false, inFunctionType: inFunctionType); 428 inFunctionType: inFunctionType);
429 break; 429 break;
430 } else if (identical(value, '{')) { 430 } else if (identical(value, '{')) {
431 token = parseOptionalFormalParameters( 431 token = parseOptionalFormalParameters(token, true,
432 token, true, inFunctionType: inFunctionType); 432 inFunctionType: inFunctionType);
433 break; 433 break;
434 } 434 }
435 token = parseFormalParameter(token, FormalParameterType.REQUIRED, 435 token = parseFormalParameter(token, FormalParameterType.REQUIRED,
436 inFunctionType: inFunctionType); 436 inFunctionType: inFunctionType);
437 } while (optional(',', token)); 437 } while (optional(',', token));
438 listener.endFormalParameters(parameterCount, begin, token); 438 listener.endFormalParameters(parameterCount, begin, token);
439 return expect(')', token); 439 return expect(')', token);
440 } 440 }
441 441
442 Token parseFormalParameter(Token token, FormalParameterType type, 442 Token parseFormalParameter(Token token, FormalParameterType type,
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
515 int parameterCount = 0; 515 int parameterCount = 0;
516 do { 516 do {
517 token = token.next; 517 token = token.next;
518 if (isNamed && optional('}', token)) { 518 if (isNamed && optional('}', token)) {
519 break; 519 break;
520 } else if (!isNamed && optional(']', token)) { 520 } else if (!isNamed && optional(']', token)) {
521 break; 521 break;
522 } 522 }
523 var type = 523 var type =
524 isNamed ? FormalParameterType.NAMED : FormalParameterType.POSITIONAL; 524 isNamed ? FormalParameterType.NAMED : FormalParameterType.POSITIONAL;
525 token = 525 token = parseFormalParameter(token, type, inFunctionType: inFunctionType);
526 parseFormalParameter(token, type, inFunctionType: inFunctionType);
527 ++parameterCount; 526 ++parameterCount;
528 } while (optional(',', token)); 527 } while (optional(',', token));
529 if (parameterCount == 0) { 528 if (parameterCount == 0) {
530 listener.reportError( 529 listener.reportError(
531 token, 530 token,
532 isNamed 531 isNamed
533 ? MessageKind.EMPTY_NAMED_PARAMETER_LIST 532 ? MessageKind.EMPTY_NAMED_PARAMETER_LIST
534 : MessageKind.EMPTY_OPTIONAL_PARAMETER_LIST); 533 : MessageKind.EMPTY_OPTIONAL_PARAMETER_LIST);
535 } 534 }
536 listener.endOptionalFormalParameters(parameterCount, begin, token); 535 listener.endOptionalFormalParameters(parameterCount, begin, token);
(...skipping 922 matching lines...) Expand 10 before | Expand all | Expand 10 after
1459 * ^ ^ 1458 * ^ ^
1460 * A call to this function must be at one of the `Function` tokens. 1459 * A call to this function must be at one of the `Function` tokens.
1461 * If `token` pointed to the first `Function` token, then the returned 1460 * If `token` pointed to the first `Function` token, then the returned
1462 * token points to the second `Function` token. 1461 * token points to the second `Function` token.
1463 */ 1462 */
1464 Token peekAfterFunctionType(Token token) { 1463 Token peekAfterFunctionType(Token token) {
1465 // Possible inputs are: 1464 // Possible inputs are:
1466 // Function( ... ) 1465 // Function( ... )
1467 // Function< ... >( ... ) 1466 // Function< ... >( ... )
1468 1467
1469 Token peek = token.next; // Skip over the Function token. 1468 Token peek = token.next; // Skip over the Function token.
1470 // If there is a generic argument to the function, skip over that one first. 1469 // If there is a generic argument to the function, skip over that one first.
1471 if (identical(peek.kind, LT_TOKEN)) { 1470 if (identical(peek.kind, LT_TOKEN)) {
1472 BeginGroupToken beginGroupToken = peek; 1471 BeginGroupToken beginGroupToken = peek;
1473 Token closeToken = beginGroupToken.endGroup; 1472 Token closeToken = beginGroupToken.endGroup;
1474 if (closeToken != null) { 1473 if (closeToken != null) {
1475 peek = closeToken.next; 1474 peek = closeToken.next;
1476 } 1475 }
1477 } 1476 }
1478 1477
1479 // Now we just need to skip over the formals. 1478 // Now we just need to skip over the formals.
(...skipping 1688 matching lines...) Expand 10 before | Expand all | Expand 10 after
3168 } 3167 }
3169 listener.handleContinueStatement(hasTarget, continueKeyword, token); 3168 listener.handleContinueStatement(hasTarget, continueKeyword, token);
3170 return expectSemicolon(token); 3169 return expectSemicolon(token);
3171 } 3170 }
3172 3171
3173 Token parseEmptyStatement(Token token) { 3172 Token parseEmptyStatement(Token token) {
3174 listener.handleEmptyStatement(token); 3173 listener.handleEmptyStatement(token);
3175 return expectSemicolon(token); 3174 return expectSemicolon(token);
3176 } 3175 }
3177 } 3176 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698