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

Side by Side Diff: pkg/analyzer/lib/src/generated/parser.dart

Issue 1043583002: Scanner/parser support for DEP 9 (null-aware operators). (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 8 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
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 // This code was auto-generated, is not intended to be edited, and is subject to 5 // This code was auto-generated, is not intended to be edited, and is subject to
6 // significant change. Please see the README file for more information. 6 // significant change. Please see the README file for more information.
7 7
8 library engine.parser; 8 library engine.parser;
9 9
10 import "dart:math" as math; 10 import "dart:math" as math;
(...skipping 676 matching lines...) Expand 10 before | Expand all | Expand 10 after
687 } 687 }
688 688
689 @override 689 @override
690 AstNode visitCompilationUnit(CompilationUnit node) { 690 AstNode visitCompilationUnit(CompilationUnit node) {
691 throw new InsufficientContextException(); 691 throw new InsufficientContextException();
692 } 692 }
693 693
694 @override 694 @override
695 AstNode visitConditionalExpression(ConditionalExpression node) { 695 AstNode visitConditionalExpression(ConditionalExpression node) {
696 if (identical(_oldNode, node.condition)) { 696 if (identical(_oldNode, node.condition)) {
697 return _parser.parseLogicalOrExpression(); 697 return _parser.parseIfNullExpression();
698 } else if (identical(_oldNode, node.thenExpression)) { 698 } else if (identical(_oldNode, node.thenExpression)) {
699 return _parser.parseExpressionWithoutCascade(); 699 return _parser.parseExpressionWithoutCascade();
700 } else if (identical(_oldNode, node.elseExpression)) { 700 } else if (identical(_oldNode, node.elseExpression)) {
701 return _parser.parseExpressionWithoutCascade(); 701 return _parser.parseExpressionWithoutCascade();
702 } 702 }
703 return _notAChild(node); 703 return _notAChild(node);
704 } 704 }
705 705
706 @override 706 @override
707 AstNode visitConstructorDeclaration(ConstructorDeclaration node) { 707 AstNode visitConstructorDeclaration(ConstructorDeclaration node) {
(...skipping 2000 matching lines...) Expand 10 before | Expand all | Expand 10 after
2708 } 2708 }
2709 return new CompilationUnit( 2709 return new CompilationUnit(
2710 firstToken, scriptTag, directives, declarations, _currentToken); 2710 firstToken, scriptTag, directives, declarations, _currentToken);
2711 } 2711 }
2712 2712
2713 /** 2713 /**
2714 * Parse a conditional expression. Return the conditional expression that was 2714 * Parse a conditional expression. Return the conditional expression that was
2715 * parsed. 2715 * parsed.
2716 * 2716 *
2717 * conditionalExpression ::= 2717 * conditionalExpression ::=
2718 * logicalOrExpression ('?' expressionWithoutCascade ':' expressionWit houtCascade)? 2718 * ifNullExpression ('?' expressionWithoutCascade ':' expressionWithou tCascade)?
2719 */ 2719 */
2720 Expression parseConditionalExpression() { 2720 Expression parseConditionalExpression() {
2721 Expression condition = parseLogicalOrExpression(); 2721 Expression condition = parseIfNullExpression();
2722 if (!_matches(TokenType.QUESTION)) { 2722 if (!_matches(TokenType.QUESTION)) {
2723 return condition; 2723 return condition;
2724 } 2724 }
2725 Token question = getAndAdvance(); 2725 Token question = getAndAdvance();
2726 Expression thenExpression = parseExpressionWithoutCascade(); 2726 Expression thenExpression = parseExpressionWithoutCascade();
2727 Token colon = _expect(TokenType.COLON); 2727 Token colon = _expect(TokenType.COLON);
2728 Expression elseExpression = parseExpressionWithoutCascade(); 2728 Expression elseExpression = parseExpressionWithoutCascade();
2729 return new ConditionalExpression( 2729 return new ConditionalExpression(
2730 condition, question, thenExpression, colon, elseExpression); 2730 condition, question, thenExpression, colon, elseExpression);
2731 } 2731 }
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after
3038 */ 3038 */
3039 FunctionExpression parseFunctionExpression() { 3039 FunctionExpression parseFunctionExpression() {
3040 FormalParameterList parameters = parseFormalParameterList(); 3040 FormalParameterList parameters = parseFormalParameterList();
3041 _validateFormalParameterList(parameters); 3041 _validateFormalParameterList(parameters);
3042 FunctionBody body = 3042 FunctionBody body =
3043 _parseFunctionBody(false, ParserErrorCode.MISSING_FUNCTION_BODY, true); 3043 _parseFunctionBody(false, ParserErrorCode.MISSING_FUNCTION_BODY, true);
3044 return new FunctionExpression(parameters, body); 3044 return new FunctionExpression(parameters, body);
3045 } 3045 }
3046 3046
3047 /** 3047 /**
3048 * Parse an if-null expression. Return the if-null expression that was
3049 * parsed.
3050 *
3051 * ifNullExpression ::= logicalOrExpression ('??' logicalOrExpression)*
3052 */
3053 Expression parseIfNullExpression() {
3054 Expression expression = parseLogicalOrExpression();
3055 while (_matches(TokenType.QUESTION_QUESTION)) {
3056 Token operator = getAndAdvance();
3057 expression = new BinaryExpression(
3058 expression, operator, parseLogicalOrExpression());
3059 }
3060 return expression;
3061 }
3062
3063 /**
3048 * Parse an implements clause. Return the implements clause that was parsed. 3064 * Parse an implements clause. Return the implements clause that was parsed.
3049 * 3065 *
3050 * implementsClause ::= 3066 * implementsClause ::=
3051 * 'implements' type (',' type)* 3067 * 'implements' type (',' type)*
3052 */ 3068 */
3053 ImplementsClause parseImplementsClause() { 3069 ImplementsClause parseImplementsClause() {
3054 Token keyword = _expectKeyword(Keyword.IMPLEMENTS); 3070 Token keyword = _expectKeyword(Keyword.IMPLEMENTS);
3055 List<TypeName> interfaces = new List<TypeName>(); 3071 List<TypeName> interfaces = new List<TypeName>();
3056 interfaces.add(parseTypeName()); 3072 interfaces.add(parseTypeName());
3057 while (_optional(TokenType.COMMA)) { 3073 while (_optional(TokenType.COMMA)) {
(...skipping 1213 matching lines...) Expand 10 before | Expand all | Expand 10 after
4271 bool wasInInitializer = _inInitializer; 4287 bool wasInInitializer = _inInitializer;
4272 _inInitializer = false; 4288 _inInitializer = false;
4273 try { 4289 try {
4274 Expression index = parseExpression2(); 4290 Expression index = parseExpression2();
4275 Token rightBracket = _expect(TokenType.CLOSE_SQUARE_BRACKET); 4291 Token rightBracket = _expect(TokenType.CLOSE_SQUARE_BRACKET);
4276 return new IndexExpression.forTarget( 4292 return new IndexExpression.forTarget(
4277 prefix, leftBracket, index, rightBracket); 4293 prefix, leftBracket, index, rightBracket);
4278 } finally { 4294 } finally {
4279 _inInitializer = wasInInitializer; 4295 _inInitializer = wasInInitializer;
4280 } 4296 }
4281 } else if (_matches(TokenType.PERIOD)) { 4297 } else if (_matches(TokenType.PERIOD) || _matches(TokenType.QUESTION_PERIOD) ) {
4282 Token period = getAndAdvance(); 4298 Token operator = getAndAdvance();
4283 return new PropertyAccess(prefix, period, parseSimpleIdentifier()); 4299 return new PropertyAccess(prefix, operator, parseSimpleIdentifier());
4284 } else { 4300 } else {
4285 if (!optional) { 4301 if (!optional) {
4286 // Report the missing selector. 4302 // Report the missing selector.
4287 _reportErrorForCurrentToken( 4303 _reportErrorForCurrentToken(
4288 ParserErrorCode.MISSING_ASSIGNABLE_SELECTOR); 4304 ParserErrorCode.MISSING_ASSIGNABLE_SELECTOR);
4289 } 4305 }
4290 return prefix; 4306 return prefix;
4291 } 4307 }
4292 } 4308 }
4293 4309
(...skipping 2414 matching lines...) Expand 10 before | Expand all | Expand 10 after
6708 * | primary selector* 6724 * | primary selector*
6709 * 6725 *
6710 * selector ::= 6726 * selector ::=
6711 * assignableSelector 6727 * assignableSelector
6712 * | argumentList 6728 * | argumentList
6713 */ 6729 */
6714 Expression _parsePostfixExpression() { 6730 Expression _parsePostfixExpression() {
6715 Expression operand = _parseAssignableExpression(true); 6731 Expression operand = _parseAssignableExpression(true);
6716 if (_matches(TokenType.OPEN_SQUARE_BRACKET) || 6732 if (_matches(TokenType.OPEN_SQUARE_BRACKET) ||
6717 _matches(TokenType.PERIOD) || 6733 _matches(TokenType.PERIOD) ||
6734 _matches(TokenType.QUESTION_PERIOD) ||
6718 _matches(TokenType.OPEN_PAREN)) { 6735 _matches(TokenType.OPEN_PAREN)) {
6719 do { 6736 do {
6720 if (_matches(TokenType.OPEN_PAREN)) { 6737 if (_matches(TokenType.OPEN_PAREN)) {
6721 ArgumentList argumentList = parseArgumentList(); 6738 ArgumentList argumentList = parseArgumentList();
6722 if (operand is PropertyAccess) { 6739 if (operand is PropertyAccess) {
6723 PropertyAccess access = operand as PropertyAccess; 6740 PropertyAccess access = operand as PropertyAccess;
6724 operand = new MethodInvocation(access.target, access.operator, 6741 operand = new MethodInvocation(access.target, access.operator,
6725 access.propertyName, argumentList); 6742 access.propertyName, argumentList);
6726 } else { 6743 } else {
6727 operand = new FunctionExpressionInvocation(operand, argumentList); 6744 operand = new FunctionExpressionInvocation(operand, argumentList);
6728 } 6745 }
6729 } else { 6746 } else {
6730 operand = _parseAssignableSelector(operand, true); 6747 operand = _parseAssignableSelector(operand, true);
6731 } 6748 }
6732 } while (_matches(TokenType.OPEN_SQUARE_BRACKET) || 6749 } while (_matches(TokenType.OPEN_SQUARE_BRACKET) ||
6733 _matches(TokenType.PERIOD) || 6750 _matches(TokenType.PERIOD) ||
6751 _matches(TokenType.QUESTION_PERIOD) ||
6734 _matches(TokenType.OPEN_PAREN)); 6752 _matches(TokenType.OPEN_PAREN));
6735 return operand; 6753 return operand;
6736 } 6754 }
6737 if (!_currentToken.type.isIncrementOperator) { 6755 if (!_currentToken.type.isIncrementOperator) {
6738 return operand; 6756 return operand;
6739 } 6757 }
6740 _ensureAssignable(operand); 6758 _ensureAssignable(operand);
6741 Token operator = getAndAdvance(); 6759 Token operator = getAndAdvance();
6742 return new PostfixExpression(operand, operator); 6760 return new PostfixExpression(operand, operator);
6743 } 6761 }
(...skipping 3844 matching lines...) Expand 10 before | Expand all | Expand 10 after
10588 } 10606 }
10589 10607
10590 /** 10608 /**
10591 * Copy resolution data from the [fromNode] to the [toNode]. 10609 * Copy resolution data from the [fromNode] to the [toNode].
10592 */ 10610 */
10593 static void copyResolutionData(AstNode fromNode, AstNode toNode) { 10611 static void copyResolutionData(AstNode fromNode, AstNode toNode) {
10594 ResolutionCopier copier = new ResolutionCopier(); 10612 ResolutionCopier copier = new ResolutionCopier();
10595 copier._isEqualNodes(fromNode, toNode); 10613 copier._isEqualNodes(fromNode, toNode);
10596 } 10614 }
10597 } 10615 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698