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

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

Issue 950613003: Fix issue 22525 (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 10 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 | pkg/analyzer/test/generated/parser_test.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) 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 4077 matching lines...) Expand 10 before | Expand all | Expand 10 after
4088 4088
4089 /** 4089 /**
4090 * Create a synthetic token with the given type. 4090 * Create a synthetic token with the given type.
4091 * 4091 *
4092 * @return the synthetic token that was created 4092 * @return the synthetic token that was created
4093 */ 4093 */
4094 Token _createSyntheticToken(TokenType type) => 4094 Token _createSyntheticToken(TokenType type) =>
4095 _injectToken(new StringToken(type, "", _currentToken.offset)); 4095 _injectToken(new StringToken(type, "", _currentToken.offset));
4096 4096
4097 /** 4097 /**
4098 * Create and return a new token with the given [type]. The token will replace
4099 * the first portion of the given [token], so it will have the same offset and
4100 * will have any comments that might have preceeded the token.
4101 */
4102 Token _createToken(Token token, TokenType type, {bool isBegin: false}) {
4103 CommentToken comments = token.precedingComments;
4104 if (comments == null) {
4105 if (isBegin) {
4106 return new BeginToken(type, token.offset);
4107 }
4108 return new Token(type, token.offset);
4109 } else if (isBegin) {
4110 return new BeginTokenWithComment(type, token.offset, comments);
4111 }
4112 return new TokenWithComment(type, token.offset, comments);
4113 }
4114
4115 /**
4098 * Check that the given expression is assignable and report an error if it isn 't. 4116 * Check that the given expression is assignable and report an error if it isn 't.
4099 * 4117 *
4100 * <pre> 4118 * <pre>
4101 * assignableExpression ::= 4119 * assignableExpression ::=
4102 * primary (arguments* assignableSelector)+ 4120 * primary (arguments* assignableSelector)+
4103 * | 'super' assignableSelector 4121 * | 'super' assignableSelector
4104 * | identifier 4122 * | identifier
4105 * 4123 *
4106 * assignableSelector ::= 4124 * assignableSelector ::=
4107 * '[' expression ']' 4125 * '[' expression ']'
(...skipping 477 matching lines...) Expand 10 before | Expand all | Expand 10 after
4585 * In particular, if the next token is either a '>>' or '>>>', the token strea m will be re-written 4603 * In particular, if the next token is either a '>>' or '>>>', the token strea m will be re-written
4586 * and `true` will be returned. 4604 * and `true` will be returned.
4587 * 4605 *
4588 * @return `true` if the current token has a type of [TokenType.GT] 4606 * @return `true` if the current token has a type of [TokenType.GT]
4589 */ 4607 */
4590 bool _matchesGt() { 4608 bool _matchesGt() {
4591 TokenType currentType = _currentToken.type; 4609 TokenType currentType = _currentToken.type;
4592 if (currentType == TokenType.GT) { 4610 if (currentType == TokenType.GT) {
4593 return true; 4611 return true;
4594 } else if (currentType == TokenType.GT_GT) { 4612 } else if (currentType == TokenType.GT_GT) {
4595 int offset = _currentToken.offset; 4613 Token first = _createToken(_currentToken, TokenType.GT);
4596 Token first = new Token(TokenType.GT, offset); 4614 Token second = new Token(TokenType.GT, _currentToken.offset + 1);
4597 Token second = new Token(TokenType.GT, offset + 1);
4598 second.setNext(_currentToken.next); 4615 second.setNext(_currentToken.next);
4599 first.setNext(second); 4616 first.setNext(second);
4600 _currentToken.previous.setNext(first); 4617 _currentToken.previous.setNext(first);
4601 _currentToken = first; 4618 _currentToken = first;
4602 return true; 4619 return true;
4603 } else if (currentType == TokenType.GT_EQ) { 4620 } else if (currentType == TokenType.GT_EQ) {
4604 int offset = _currentToken.offset; 4621 Token first = _createToken(_currentToken, TokenType.GT);
4605 Token first = new Token(TokenType.GT, offset); 4622 Token second = new Token(TokenType.EQ, _currentToken.offset + 1);
4606 Token second = new Token(TokenType.EQ, offset + 1);
4607 second.setNext(_currentToken.next); 4623 second.setNext(_currentToken.next);
4608 first.setNext(second); 4624 first.setNext(second);
4609 _currentToken.previous.setNext(first); 4625 _currentToken.previous.setNext(first);
4610 _currentToken = first; 4626 _currentToken = first;
4611 return true; 4627 return true;
4612 } else if (currentType == TokenType.GT_GT_EQ) { 4628 } else if (currentType == TokenType.GT_GT_EQ) {
4613 int offset = _currentToken.offset; 4629 int offset = _currentToken.offset;
4614 Token first = new Token(TokenType.GT, offset); 4630 Token first = _createToken(_currentToken, TokenType.GT);
4615 Token second = new Token(TokenType.GT, offset + 1); 4631 Token second = new Token(TokenType.GT, offset + 1);
4616 Token third = new Token(TokenType.EQ, offset + 2); 4632 Token third = new Token(TokenType.EQ, offset + 2);
4617 third.setNext(_currentToken.next); 4633 third.setNext(_currentToken.next);
4618 second.setNext(third); 4634 second.setNext(third);
4619 first.setNext(second); 4635 first.setNext(second);
4620 _currentToken.previous.setNext(first); 4636 _currentToken.previous.setNext(first);
4621 _currentToken = first; 4637 _currentToken = first;
4622 return true; 4638 return true;
4623 } 4639 }
4624 return false; 4640 return false;
(...skipping 1453 matching lines...) Expand 10 before | Expand all | Expand 10 after
6078 6094
6079 EnumConstantDeclaration _parseEnumConstantDeclaration() { 6095 EnumConstantDeclaration _parseEnumConstantDeclaration() {
6080 CommentAndMetadata commentAndMetadata = _parseCommentAndMetadata(); 6096 CommentAndMetadata commentAndMetadata = _parseCommentAndMetadata();
6081 SimpleIdentifier name; 6097 SimpleIdentifier name;
6082 if (_matchesIdentifier()) { 6098 if (_matchesIdentifier()) {
6083 name = parseSimpleIdentifier(); 6099 name = parseSimpleIdentifier();
6084 } else { 6100 } else {
6085 name = _createSyntheticIdentifier(); 6101 name = _createSyntheticIdentifier();
6086 } 6102 }
6087 if (commentAndMetadata.metadata.isNotEmpty) { 6103 if (commentAndMetadata.metadata.isNotEmpty) {
6088 _reportErrorForNode(ParserErrorCode.ANNOTATION_ON_ENUM_CONSTANT, commentAn dMetadata.metadata[0]); 6104 _reportErrorForNode(
6105 ParserErrorCode.ANNOTATION_ON_ENUM_CONSTANT,
6106 commentAndMetadata.metadata[0]);
6089 } 6107 }
6090 return new EnumConstantDeclaration( 6108 return new EnumConstantDeclaration(
6091 commentAndMetadata.comment, 6109 commentAndMetadata.comment,
6092 commentAndMetadata.metadata, 6110 commentAndMetadata.metadata,
6093 name); 6111 name);
6094 } 6112 }
6095 6113
6096 /** 6114 /**
6097 * Parse an enum declaration. 6115 * Parse an enum declaration.
6098 * 6116 *
(...skipping 950 matching lines...) Expand 10 before | Expand all | Expand 10 after
7049 * no modifier 7067 * no modifier
7050 * @param typeArguments the type arguments appearing before the literal, or `n ull` if there 7068 * @param typeArguments the type arguments appearing before the literal, or `n ull` if there
7051 * are no type arguments 7069 * are no type arguments
7052 * @return the list literal that was parsed 7070 * @return the list literal that was parsed
7053 */ 7071 */
7054 ListLiteral _parseListLiteral(Token modifier, 7072 ListLiteral _parseListLiteral(Token modifier,
7055 TypeArgumentList typeArguments) { 7073 TypeArgumentList typeArguments) {
7056 // may be empty list literal 7074 // may be empty list literal
7057 if (_matches(TokenType.INDEX)) { 7075 if (_matches(TokenType.INDEX)) {
7058 BeginToken leftBracket = 7076 BeginToken leftBracket =
7059 new BeginToken(TokenType.OPEN_SQUARE_BRACKET, _currentToken.offset); 7077 _createToken(_currentToken, TokenType.OPEN_SQUARE_BRACKET, isBegin: tr ue);
7060 Token rightBracket = 7078 Token rightBracket =
7061 new Token(TokenType.CLOSE_SQUARE_BRACKET, _currentToken.offset + 1); 7079 new Token(TokenType.CLOSE_SQUARE_BRACKET, _currentToken.offset + 1);
7062 leftBracket.endToken = rightBracket; 7080 leftBracket.endToken = rightBracket;
7063 rightBracket.setNext(_currentToken.next); 7081 rightBracket.setNext(_currentToken.next);
7064 leftBracket.setNext(rightBracket); 7082 leftBracket.setNext(rightBracket);
7065 _currentToken.previous.setNext(leftBracket); 7083 _currentToken.previous.setNext(leftBracket);
7066 _currentToken = _currentToken.next; 7084 _currentToken = _currentToken.next;
7067 return new ListLiteral( 7085 return new ListLiteral(
7068 modifier, 7086 modifier,
7069 typeArguments, 7087 typeArguments,
(...skipping 1521 matching lines...) Expand 10 before | Expand all | Expand 10 after
8591 return new PrefixExpression(operator, _parseUnaryExpression()); 8609 return new PrefixExpression(operator, _parseUnaryExpression());
8592 } 8610 }
8593 // 8611 //
8594 // Even though it is not valid to use an incrementing operator 8612 // Even though it is not valid to use an incrementing operator
8595 // ('++' or '--') before 'super', we can (and therefore must) interpret 8613 // ('++' or '--') before 'super', we can (and therefore must) interpret
8596 // "--super" as semantically equivalent to "-(-super)". Unfortunately, 8614 // "--super" as semantically equivalent to "-(-super)". Unfortunately,
8597 // we cannot do the same for "++super" because "+super" is also not 8615 // we cannot do the same for "++super" because "+super" is also not
8598 // valid. 8616 // valid.
8599 // 8617 //
8600 if (operator.type == TokenType.MINUS_MINUS) { 8618 if (operator.type == TokenType.MINUS_MINUS) {
8601 int offset = operator.offset; 8619 Token firstOperator = _createToken(operator, TokenType.MINUS);
8602 Token firstOperator = new Token(TokenType.MINUS, offset); 8620 Token secondOperator =
8603 Token secondOperator = new Token(TokenType.MINUS, offset + 1); 8621 new Token(TokenType.MINUS, operator.offset + 1);
8604 secondOperator.setNext(_currentToken); 8622 secondOperator.setNext(_currentToken);
8605 firstOperator.setNext(secondOperator); 8623 firstOperator.setNext(secondOperator);
8606 operator.previous.setNext(firstOperator); 8624 operator.previous.setNext(firstOperator);
8607 return new PrefixExpression( 8625 return new PrefixExpression(
8608 firstOperator, 8626 firstOperator,
8609 new PrefixExpression(secondOperator, new SuperExpression(getAndAdv ance()))); 8627 new PrefixExpression(secondOperator, new SuperExpression(getAndAdv ance())));
8610 } else { 8628 } else {
8611 // Invalid operator before 'super' 8629 // Invalid operator before 'super'
8612 _reportErrorForCurrentToken( 8630 _reportErrorForCurrentToken(
8613 ParserErrorCode.INVALID_OPERATOR_FOR_SUPER, 8631 ParserErrorCode.INVALID_OPERATOR_FOR_SUPER,
(...skipping 1397 matching lines...) Expand 10 before | Expand all | Expand 10 after
10011 10029
10012 static const ParserErrorCode ABSTRACT_TOP_LEVEL_VARIABLE = 10030 static const ParserErrorCode ABSTRACT_TOP_LEVEL_VARIABLE =
10013 const ParserErrorCode( 10031 const ParserErrorCode(
10014 'ABSTRACT_TOP_LEVEL_VARIABLE', 10032 'ABSTRACT_TOP_LEVEL_VARIABLE',
10015 "Top-level variables cannot be declared to be 'abstract'"); 10033 "Top-level variables cannot be declared to be 'abstract'");
10016 10034
10017 static const ParserErrorCode ABSTRACT_TYPEDEF = const ParserErrorCode( 10035 static const ParserErrorCode ABSTRACT_TYPEDEF = const ParserErrorCode(
10018 'ABSTRACT_TYPEDEF', 10036 'ABSTRACT_TYPEDEF',
10019 "Type aliases cannot be declared to be 'abstract'"); 10037 "Type aliases cannot be declared to be 'abstract'");
10020 10038
10021 static const ParserErrorCode ANNOTATION_ON_ENUM_CONSTANT = const ParserErrorCo de( 10039 static const ParserErrorCode ANNOTATION_ON_ENUM_CONSTANT =
10022 'ANNOTATION_ON_ENUM_CONSTANT', 10040 const ParserErrorCode(
10023 "Enum constants cannot have annotations"); 10041 'ANNOTATION_ON_ENUM_CONSTANT',
10042 "Enum constants cannot have annotations");
10024 10043
10025 static const ParserErrorCode ASSERT_DOES_NOT_TAKE_ASSIGNMENT = 10044 static const ParserErrorCode ASSERT_DOES_NOT_TAKE_ASSIGNMENT =
10026 const ParserErrorCode( 10045 const ParserErrorCode(
10027 'ASSERT_DOES_NOT_TAKE_ASSIGNMENT', 10046 'ASSERT_DOES_NOT_TAKE_ASSIGNMENT',
10028 "Assert cannot be called on an assignment"); 10047 "Assert cannot be called on an assignment");
10029 10048
10030 static const ParserErrorCode ASSERT_DOES_NOT_TAKE_CASCADE = 10049 static const ParserErrorCode ASSERT_DOES_NOT_TAKE_CASCADE =
10031 const ParserErrorCode( 10050 const ParserErrorCode(
10032 'ASSERT_DOES_NOT_TAKE_CASCADE', 10051 'ASSERT_DOES_NOT_TAKE_CASCADE',
10033 "Assert cannot be called on cascade"); 10052 "Assert cannot be called on cascade");
(...skipping 2092 matching lines...) Expand 10 before | Expand all | Expand 10 after
12126 * Copy resolution data from one node to another. 12145 * Copy resolution data from one node to another.
12127 * 12146 *
12128 * @param fromNode the node from which resolution information will be copied 12147 * @param fromNode the node from which resolution information will be copied
12129 * @param toNode the node to which resolution information will be copied 12148 * @param toNode the node to which resolution information will be copied
12130 */ 12149 */
12131 static void copyResolutionData(AstNode fromNode, AstNode toNode) { 12150 static void copyResolutionData(AstNode fromNode, AstNode toNode) {
12132 ResolutionCopier copier = new ResolutionCopier(); 12151 ResolutionCopier copier = new ResolutionCopier();
12133 copier._isEqualNodes(fromNode, toNode); 12152 copier._isEqualNodes(fromNode, toNode);
12134 } 12153 }
12135 } 12154 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analyzer/test/generated/parser_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698