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

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

Issue 489173002: New analyzer snapshot. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 4 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:collection'; 10 import 'dart:collection';
(...skipping 1879 matching lines...) Expand 10 before | Expand all | Expand 10 after
1890 _validateModifiersForOperator(modifiers); 1890 _validateModifiersForOperator(modifiers);
1891 return _parseOperator(commentAndMetadata, modifiers.externalKeyword, null) ; 1891 return _parseOperator(commentAndMetadata, modifiers.externalKeyword, null) ;
1892 } else if (!_matchesIdentifier()) { 1892 } else if (!_matchesIdentifier()) {
1893 if (_isOperator(_currentToken)) { 1893 if (_isOperator(_currentToken)) {
1894 // 1894 //
1895 // We appear to have found an operator declaration without the 'operator ' keyword. 1895 // We appear to have found an operator declaration without the 'operator ' keyword.
1896 // 1896 //
1897 _validateModifiersForOperator(modifiers); 1897 _validateModifiersForOperator(modifiers);
1898 return _parseOperator(commentAndMetadata, modifiers.externalKeyword, nul l); 1898 return _parseOperator(commentAndMetadata, modifiers.externalKeyword, nul l);
1899 } 1899 }
1900 Token keyword = modifiers.varKeyword;
1901 if (keyword == null) {
1902 keyword = modifiers.finalKeyword;
1903 }
1904 if (keyword == null) {
1905 keyword = modifiers.constKeyword;
1906 }
1907 if (keyword != null) {
1908 //
1909 // We appear to have found an incomplete field declaration.
1910 //
1911 _reportErrorForCurrentToken(ParserErrorCode.MISSING_IDENTIFIER, []);
1912 List<VariableDeclaration> variables = new List<VariableDeclaration>();
1913 variables.add(new VariableDeclaration(null, null, _createSyntheticIdenti fier(), null, null));
1914 return new FieldDeclaration(commentAndMetadata.comment, commentAndMetada ta.metadata, null, new VariableDeclarationList(null, null, keyword, null, variab les), _expectSemicolon());
1915 }
1900 _reportErrorForToken(ParserErrorCode.EXPECTED_CLASS_MEMBER, _currentToken, []); 1916 _reportErrorForToken(ParserErrorCode.EXPECTED_CLASS_MEMBER, _currentToken, []);
1901 if (commentAndMetadata.comment != null || !commentAndMetadata.metadata.isE mpty) { 1917 if (commentAndMetadata.comment != null || !commentAndMetadata.metadata.isE mpty) {
1902 // 1918 //
1903 // We appear to have found an incomplete declaration at the end of the c lass. At this point 1919 // We appear to have found an incomplete declaration at the end of the c lass. At this point
1904 // it consists of a metadata, which we don't want to loose, so we'll tre at it as a method 1920 // it consists of a metadata, which we don't want to loose, so we'll tre at it as a method
1905 // declaration with a missing name, parameters and empty body. 1921 // declaration with a missing name, parameters and empty body.
1906 // 1922 //
1907 return new MethodDeclaration(commentAndMetadata.comment, commentAndMetad ata.metadata, null, null, null, null, null, _createSyntheticIdentifier(), new Fo rmalParameterList(null, new List<FormalParameter>(), null, null, null), new Empt yFunctionBody(_createSyntheticToken(TokenType.SEMICOLON))); 1923 return new MethodDeclaration(commentAndMetadata.comment, commentAndMetad ata.metadata, null, null, null, null, null, _createSyntheticIdentifier(), new Fo rmalParameterList(null, new List<FormalParameter>(), null, null, null), new Empt yFunctionBody(_createSyntheticToken(TokenType.SEMICOLON)));
1908 } 1924 }
1909 return null; 1925 return null;
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
2139 * </pre> 2155 * </pre>
2140 * 2156 *
2141 * @return the expression that was parsed 2157 * @return the expression that was parsed
2142 */ 2158 */
2143 Expression parseExpression2() { 2159 Expression parseExpression2() {
2144 if (_matchesKeyword(Keyword.THROW)) { 2160 if (_matchesKeyword(Keyword.THROW)) {
2145 return _parseThrowExpression(); 2161 return _parseThrowExpression();
2146 } else if (_matchesKeyword(Keyword.RETHROW)) { 2162 } else if (_matchesKeyword(Keyword.RETHROW)) {
2147 // TODO(brianwilkerson) Rethrow is a statement again. 2163 // TODO(brianwilkerson) Rethrow is a statement again.
2148 return _parseRethrowExpression(); 2164 return _parseRethrowExpression();
2149 } else if (_parseAsync && _matchesString(_AWAIT)) {
2150 return _parseAwaitExpression();
2151 } 2165 }
2152 // 2166 //
2153 // assignableExpression is a subset of conditionalExpression, so we can pars e a conditional 2167 // assignableExpression is a subset of conditionalExpression, so we can pars e a conditional
2154 // expression and then determine whether it is followed by an assignmentOper ator, checking for 2168 // expression and then determine whether it is followed by an assignmentOper ator, checking for
2155 // conformance to the restricted grammar after making that determination. 2169 // conformance to the restricted grammar after making that determination.
2156 // 2170 //
2157 Expression expression = parseConditionalExpression(); 2171 Expression expression = parseConditionalExpression();
2158 TokenType tokenType = _currentToken.type; 2172 TokenType tokenType = _currentToken.type;
2159 if (tokenType == TokenType.PERIOD_PERIOD) { 2173 if (tokenType == TokenType.PERIOD_PERIOD) {
2160 List<Expression> cascadeSections = new List<Expression>(); 2174 List<Expression> cascadeSections = new List<Expression>();
(...skipping 1476 matching lines...) Expand 10 before | Expand all | Expand 10 after
3637 } 3651 }
3638 return prefix; 3652 return prefix;
3639 } 3653 }
3640 } 3654 }
3641 3655
3642 /** 3656 /**
3643 * Parse a await expression. 3657 * Parse a await expression.
3644 * 3658 *
3645 * <pre> 3659 * <pre>
3646 * awaitExpression ::= 3660 * awaitExpression ::=
3647 * 'await' expression ';' 3661 * 'await' unaryExpression
3648 * </pre> 3662 * </pre>
3649 * 3663 *
3650 * @return the await expression that was parsed 3664 * @return the await expression that was parsed
3651 */ 3665 */
3652 AwaitExpression _parseAwaitExpression() { 3666 AwaitExpression _parseAwaitExpression() {
3653 Token awaitToken = andAdvance; 3667 Token awaitToken = andAdvance;
3654 Expression expression = parseExpression2(); 3668 Expression expression = _parseUnaryExpression();
3655 Token semicolon = _expect(TokenType.SEMICOLON); 3669 return new AwaitExpression(awaitToken, expression);
3656 return new AwaitExpression(awaitToken, expression, semicolon);
3657 } 3670 }
3658 3671
3659 /** 3672 /**
3660 * Parse a bitwise and expression. 3673 * Parse a bitwise and expression.
3661 * 3674 *
3662 * <pre> 3675 * <pre>
3663 * bitwiseAndExpression ::= 3676 * bitwiseAndExpression ::=
3664 * shiftExpression ('&' shiftExpression)* 3677 * shiftExpression ('&' shiftExpression)*
3665 * | 'super' ('&' shiftExpression)+ 3678 * | 'super' ('&' shiftExpression)+
3666 * </pre> 3679 * </pre>
(...skipping 569 matching lines...) Expand 10 before | Expand all | Expand 10 after
4236 _reportErrorForToken(ParserErrorCode.EXPECTED_EXECUTABLE, _currentToken, []); 4249 _reportErrorForToken(ParserErrorCode.EXPECTED_EXECUTABLE, _currentToken, []);
4237 return null; 4250 return null;
4238 } 4251 }
4239 } else if ((_matchesKeyword(Keyword.GET) || _matchesKeyword(Keyword.SET)) && _tokenMatchesIdentifier(_peek())) { 4252 } else if ((_matchesKeyword(Keyword.GET) || _matchesKeyword(Keyword.SET)) && _tokenMatchesIdentifier(_peek())) {
4240 _validateModifiersForTopLevelFunction(modifiers); 4253 _validateModifiersForTopLevelFunction(modifiers);
4241 return _parseFunctionDeclaration(commentAndMetadata, modifiers.externalKey word, null); 4254 return _parseFunctionDeclaration(commentAndMetadata, modifiers.externalKey word, null);
4242 } else if (_matchesKeyword(Keyword.OPERATOR) && _isOperator(_peek())) { 4255 } else if (_matchesKeyword(Keyword.OPERATOR) && _isOperator(_peek())) {
4243 _reportErrorForToken(ParserErrorCode.TOP_LEVEL_OPERATOR, _currentToken, [] ); 4256 _reportErrorForToken(ParserErrorCode.TOP_LEVEL_OPERATOR, _currentToken, [] );
4244 return _convertToFunctionDeclaration(_parseOperator(commentAndMetadata, mo difiers.externalKeyword, null)); 4257 return _convertToFunctionDeclaration(_parseOperator(commentAndMetadata, mo difiers.externalKeyword, null));
4245 } else if (!_matchesIdentifier()) { 4258 } else if (!_matchesIdentifier()) {
4259 Token keyword = modifiers.varKeyword;
4260 if (keyword == null) {
4261 keyword = modifiers.finalKeyword;
4262 }
4263 if (keyword == null) {
4264 keyword = modifiers.constKeyword;
4265 }
4266 if (keyword != null) {
4267 //
4268 // We appear to have found an incomplete top-level variable declaration.
4269 //
4270 _reportErrorForCurrentToken(ParserErrorCode.MISSING_IDENTIFIER, []);
4271 List<VariableDeclaration> variables = new List<VariableDeclaration>();
4272 variables.add(new VariableDeclaration(null, null, _createSyntheticIdenti fier(), null, null));
4273 return new TopLevelVariableDeclaration(commentAndMetadata.comment, comme ntAndMetadata.metadata, new VariableDeclarationList(null, null, keyword, null, v ariables), _expectSemicolon());
4274 }
4246 _reportErrorForToken(ParserErrorCode.EXPECTED_EXECUTABLE, _currentToken, [ ]); 4275 _reportErrorForToken(ParserErrorCode.EXPECTED_EXECUTABLE, _currentToken, [ ]);
4247 return null; 4276 return null;
4248 } else if (_tokenMatches(_peek(), TokenType.OPEN_PAREN)) { 4277 } else if (_tokenMatches(_peek(), TokenType.OPEN_PAREN)) {
4249 _validateModifiersForTopLevelFunction(modifiers); 4278 _validateModifiersForTopLevelFunction(modifiers);
4250 return _parseFunctionDeclaration(commentAndMetadata, modifiers.externalKey word, null); 4279 return _parseFunctionDeclaration(commentAndMetadata, modifiers.externalKey word, null);
4251 } else if (_peek().matchesAny([TokenType.EQ, TokenType.COMMA, TokenType.SEMI COLON])) { 4280 } else if (_peek().matchesAny([TokenType.EQ, TokenType.COMMA, TokenType.SEMI COLON])) {
4252 if (modifiers.constKeyword == null && modifiers.finalKeyword == null && mo difiers.varKeyword == null) { 4281 if (modifiers.constKeyword == null && modifiers.finalKeyword == null && mo difiers.varKeyword == null) {
4253 _reportErrorForCurrentToken(ParserErrorCode.MISSING_CONST_FINAL_VAR_OR_T YPE, []); 4282 _reportErrorForCurrentToken(ParserErrorCode.MISSING_CONST_FINAL_VAR_OR_T YPE, []);
4254 } 4283 }
4255 return new TopLevelVariableDeclaration(commentAndMetadata.comment, comment AndMetadata.metadata, _parseVariableDeclarationListAfterType(null, _validateModi fiersForTopLevelVariable(modifiers), null), _expect(TokenType.SEMICOLON)); 4284 return new TopLevelVariableDeclaration(commentAndMetadata.comment, comment AndMetadata.metadata, _parseVariableDeclarationListAfterType(null, _validateModi fiersForTopLevelVariable(modifiers), null), _expect(TokenType.SEMICOLON));
(...skipping 2244 matching lines...) Expand 10 before | Expand all | Expand 10 after
6500 } 6529 }
6501 return _parseFunctionTypeAlias(commentAndMetadata, keyword); 6530 return _parseFunctionTypeAlias(commentAndMetadata, keyword);
6502 } 6531 }
6503 6532
6504 /** 6533 /**
6505 * Parse a unary expression. 6534 * Parse a unary expression.
6506 * 6535 *
6507 * <pre> 6536 * <pre>
6508 * unaryExpression ::= 6537 * unaryExpression ::=
6509 * prefixOperator unaryExpression 6538 * prefixOperator unaryExpression
6539 * | awaitExpression
6510 * | postfixExpression 6540 * | postfixExpression
6511 * | unaryOperator 'super' 6541 * | unaryOperator 'super'
6512 * | '-' 'super' 6542 * | '-' 'super'
6513 * | incrementOperator assignableExpression 6543 * | incrementOperator assignableExpression
6514 * </pre> 6544 * </pre>
6515 * 6545 *
6516 * @return the unary expression that was parsed 6546 * @return the unary expression that was parsed
6517 */ 6547 */
6518 Expression _parseUnaryExpression() { 6548 Expression _parseUnaryExpression() {
6519 if (_matches(TokenType.MINUS) || _matches(TokenType.BANG) || _matches(TokenT ype.TILDE)) { 6549 if (_matches(TokenType.MINUS) || _matches(TokenType.BANG) || _matches(TokenT ype.TILDE)) {
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
6552 } else { 6582 } else {
6553 // Invalid operator before 'super' 6583 // Invalid operator before 'super'
6554 _reportErrorForCurrentToken(ParserErrorCode.INVALID_OPERATOR_FOR_SUPER , [operator.lexeme]); 6584 _reportErrorForCurrentToken(ParserErrorCode.INVALID_OPERATOR_FOR_SUPER , [operator.lexeme]);
6555 return new PrefixExpression(operator, new SuperExpression(andAdvance)) ; 6585 return new PrefixExpression(operator, new SuperExpression(andAdvance)) ;
6556 } 6586 }
6557 } 6587 }
6558 return new PrefixExpression(operator, _parseAssignableExpression(false)); 6588 return new PrefixExpression(operator, _parseAssignableExpression(false));
6559 } else if (_matches(TokenType.PLUS)) { 6589 } else if (_matches(TokenType.PLUS)) {
6560 _reportErrorForCurrentToken(ParserErrorCode.MISSING_IDENTIFIER, []); 6590 _reportErrorForCurrentToken(ParserErrorCode.MISSING_IDENTIFIER, []);
6561 return _createSyntheticIdentifier(); 6591 return _createSyntheticIdentifier();
6592 } else if (_parseAsync && _matchesString(_AWAIT)) {
6593 return _parseAwaitExpression();
6562 } 6594 }
6563 return _parsePostfixExpression(); 6595 return _parsePostfixExpression();
6564 } 6596 }
6565 6597
6566 /** 6598 /**
6567 * Parse a variable declaration. 6599 * Parse a variable declaration.
6568 * 6600 *
6569 * <pre> 6601 * <pre>
6570 * variableDeclaration ::= 6602 * variableDeclaration ::=
6571 * identifier ('=' expression)? 6603 * identifier ('=' expression)?
(...skipping 1717 matching lines...) Expand 10 before | Expand all | Expand 10 after
8289 toNode.staticElement = node.staticElement; 8321 toNode.staticElement = node.staticElement;
8290 toNode.staticType = node.staticType; 8322 toNode.staticType = node.staticType;
8291 return true; 8323 return true;
8292 } 8324 }
8293 return false; 8325 return false;
8294 } 8326 }
8295 8327
8296 @override 8328 @override
8297 bool visitAwaitExpression(AwaitExpression node) { 8329 bool visitAwaitExpression(AwaitExpression node) {
8298 AwaitExpression toNode = this._toNode as AwaitExpression; 8330 AwaitExpression toNode = this._toNode as AwaitExpression;
8299 return javaBooleanAnd(javaBooleanAnd(_isEqualTokens(node.awaitKeyword, toNod e.awaitKeyword), _isEqualNodes(node.expression, toNode.expression)), _isEqualTok ens(node.semicolon, toNode.semicolon)); 8331 return javaBooleanAnd(_isEqualTokens(node.awaitKeyword, toNode.awaitKeyword) , _isEqualNodes(node.expression, toNode.expression));
8300 } 8332 }
8301 8333
8302 @override 8334 @override
8303 bool visitBinaryExpression(BinaryExpression node) { 8335 bool visitBinaryExpression(BinaryExpression node) {
8304 BinaryExpression toNode = this._toNode as BinaryExpression; 8336 BinaryExpression toNode = this._toNode as BinaryExpression;
8305 if (javaBooleanAnd(javaBooleanAnd(_isEqualNodes(node.leftOperand, toNode.lef tOperand), _isEqualTokens(node.operator, toNode.operator)), _isEqualNodes(node.r ightOperand, toNode.rightOperand))) { 8337 if (javaBooleanAnd(javaBooleanAnd(_isEqualNodes(node.leftOperand, toNode.lef tOperand), _isEqualTokens(node.operator, toNode.operator)), _isEqualNodes(node.r ightOperand, toNode.rightOperand))) {
8306 toNode.propagatedElement = node.propagatedElement; 8338 toNode.propagatedElement = node.propagatedElement;
8307 toNode.propagatedType = node.propagatedType; 8339 toNode.propagatedType = node.propagatedType;
8308 toNode.staticElement = node.staticElement; 8340 toNode.staticElement = node.staticElement;
8309 toNode.staticType = node.staticType; 8341 toNode.staticType = node.staticType;
(...skipping 1113 matching lines...) Expand 10 before | Expand all | Expand 10 after
9423 return trampoline(target, arguments[0], arguments[1]); 9455 return trampoline(target, arguments[0], arguments[1]);
9424 case 3: 9456 case 3:
9425 return trampoline(target, arguments[0], arguments[1], arguments[2]); 9457 return trampoline(target, arguments[0], arguments[1], arguments[2]);
9426 case 4: 9458 case 4:
9427 return trampoline(target, arguments[0], arguments[1], arguments[2], argu ments[3]); 9459 return trampoline(target, arguments[0], arguments[1], arguments[2], argu ments[3]);
9428 default: 9460 default:
9429 throw new IllegalArgumentException("Not implemented for > 4 arguments"); 9461 throw new IllegalArgumentException("Not implemented for > 4 arguments");
9430 } 9462 }
9431 } 9463 }
9432 } 9464 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/generated/java_core.dart ('k') | pkg/analyzer/lib/src/generated/resolver.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698