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

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

Issue 1008583002: Fix hints (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 9 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 2201 matching lines...) Expand 10 before | Expand all | Expand 10 after
2212 _inInitializer = false; 2212 _inInitializer = false;
2213 try { 2213 try {
2214 Expression argument = parseArgument(); 2214 Expression argument = parseArgument();
2215 arguments.add(argument); 2215 arguments.add(argument);
2216 bool foundNamedArgument = argument is NamedExpression; 2216 bool foundNamedArgument = argument is NamedExpression;
2217 bool generatedError = false; 2217 bool generatedError = false;
2218 while (_optional(TokenType.COMMA)) { 2218 while (_optional(TokenType.COMMA)) {
2219 argument = parseArgument(); 2219 argument = parseArgument();
2220 arguments.add(argument); 2220 arguments.add(argument);
2221 if (foundNamedArgument) { 2221 if (foundNamedArgument) {
2222 bool blankArgument = argument is SimpleIdentifier && 2222 bool blankArgument =
2223 (argument as SimpleIdentifier).name.isEmpty; 2223 argument is SimpleIdentifier && argument.name.isEmpty;
2224 if (!generatedError && 2224 if (!generatedError &&
2225 !(argument is NamedExpression && !blankArgument)) { 2225 !(argument is NamedExpression && !blankArgument)) {
2226 // Report the error, once, but allow the arguments to be in any 2226 // Report the error, once, but allow the arguments to be in any
2227 // order in the AST. 2227 // order in the AST.
2228 _reportErrorForCurrentToken( 2228 _reportErrorForCurrentToken(
2229 ParserErrorCode.POSITIONAL_AFTER_NAMED_ARGUMENT); 2229 ParserErrorCode.POSITIONAL_AFTER_NAMED_ARGUMENT);
2230 generatedError = true; 2230 generatedError = true;
2231 } 2231 }
2232 } else if (argument is NamedExpression) { 2232 } else if (argument is NamedExpression) {
2233 foundNamedArgument = true; 2233 foundNamedArgument = true;
(...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after
2678 partOfDirectiveFound = true; 2678 partOfDirectiveFound = true;
2679 } 2679 }
2680 } else { 2680 } else {
2681 if (partOfDirectiveFound) { 2681 if (partOfDirectiveFound) {
2682 _reportErrorForToken(ParserErrorCode.NON_PART_OF_DIRECTIVE_IN_PART, 2682 _reportErrorForToken(ParserErrorCode.NON_PART_OF_DIRECTIVE_IN_PART,
2683 directive.keyword); 2683 directive.keyword);
2684 } 2684 }
2685 } 2685 }
2686 directives.add(directive); 2686 directives.add(directive);
2687 } else if (_matches(TokenType.SEMICOLON)) { 2687 } else if (_matches(TokenType.SEMICOLON)) {
2688 _reportErrorForToken(ParserErrorCode.UNEXPECTED_TOKEN, _currentToken, [ 2688 _reportErrorForToken(ParserErrorCode.UNEXPECTED_TOKEN, _currentToken,
2689 _currentToken.lexeme 2689 [_currentToken.lexeme]);
2690 ]);
2691 _advance(); 2690 _advance();
2692 } else { 2691 } else {
2693 CompilationUnitMember member = 2692 CompilationUnitMember member =
2694 _parseCompilationUnitMember(commentAndMetadata); 2693 _parseCompilationUnitMember(commentAndMetadata);
2695 if (member != null) { 2694 if (member != null) {
2696 declarations.add(member); 2695 declarations.add(member);
2697 } 2696 }
2698 } 2697 }
2699 if (identical(_currentToken, memberStart)) { 2698 if (identical(_currentToken, memberStart)) {
2700 _reportErrorForToken(ParserErrorCode.UNEXPECTED_TOKEN, _currentToken, [ 2699 _reportErrorForToken(ParserErrorCode.UNEXPECTED_TOKEN, _currentToken,
2701 _currentToken.lexeme 2700 [_currentToken.lexeme]);
2702 ]);
2703 _advance(); 2701 _advance();
2704 while (!_matches(TokenType.EOF) && 2702 while (!_matches(TokenType.EOF) &&
2705 !_couldBeStartOfCompilationUnitMember()) { 2703 !_couldBeStartOfCompilationUnitMember()) {
2706 _advance(); 2704 _advance();
2707 } 2705 }
2708 } 2706 }
2709 memberStart = _currentToken; 2707 memberStart = _currentToken;
2710 } 2708 }
2711 return new CompilationUnit( 2709 return new CompilationUnit(
2712 firstToken, scriptTag, directives, declarations, _currentToken); 2710 firstToken, scriptTag, directives, declarations, _currentToken);
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
2975 rightSquareBracket = getAndAdvance(); 2973 rightSquareBracket = getAndAdvance();
2976 currentParameters = normalParameters; 2974 currentParameters = normalParameters;
2977 if (leftSquareBracket == null) { 2975 if (leftSquareBracket == null) {
2978 if (leftCurlyBracket != null) { 2976 if (leftCurlyBracket != null) {
2979 _reportErrorForCurrentToken( 2977 _reportErrorForCurrentToken(
2980 ParserErrorCode.WRONG_TERMINATOR_FOR_PARAMETER_GROUP, ["}"]); 2978 ParserErrorCode.WRONG_TERMINATOR_FOR_PARAMETER_GROUP, ["}"]);
2981 rightCurlyBracket = rightSquareBracket; 2979 rightCurlyBracket = rightSquareBracket;
2982 rightSquareBracket = null; 2980 rightSquareBracket = null;
2983 } else { 2981 } else {
2984 _reportErrorForCurrentToken( 2982 _reportErrorForCurrentToken(
2985 ParserErrorCode.UNEXPECTED_TERMINATOR_FOR_PARAMETER_GROUP, [ 2983 ParserErrorCode.UNEXPECTED_TERMINATOR_FOR_PARAMETER_GROUP,
2986 "[" 2984 ["["]);
2987 ]);
2988 } 2985 }
2989 } 2986 }
2990 kind = ParameterKind.REQUIRED; 2987 kind = ParameterKind.REQUIRED;
2991 } else if (_matches(TokenType.CLOSE_CURLY_BRACKET)) { 2988 } else if (_matches(TokenType.CLOSE_CURLY_BRACKET)) {
2992 rightCurlyBracket = getAndAdvance(); 2989 rightCurlyBracket = getAndAdvance();
2993 currentParameters = normalParameters; 2990 currentParameters = normalParameters;
2994 if (leftCurlyBracket == null) { 2991 if (leftCurlyBracket == null) {
2995 if (leftSquareBracket != null) { 2992 if (leftSquareBracket != null) {
2996 _reportErrorForCurrentToken( 2993 _reportErrorForCurrentToken(
2997 ParserErrorCode.WRONG_TERMINATOR_FOR_PARAMETER_GROUP, ["]"]); 2994 ParserErrorCode.WRONG_TERMINATOR_FOR_PARAMETER_GROUP, ["]"]);
2998 rightSquareBracket = rightCurlyBracket; 2995 rightSquareBracket = rightCurlyBracket;
2999 rightCurlyBracket = null; 2996 rightCurlyBracket = null;
3000 } else { 2997 } else {
3001 _reportErrorForCurrentToken( 2998 _reportErrorForCurrentToken(
3002 ParserErrorCode.UNEXPECTED_TERMINATOR_FOR_PARAMETER_GROUP, [ 2999 ParserErrorCode.UNEXPECTED_TERMINATOR_FOR_PARAMETER_GROUP,
3003 "{" 3000 ["{"]);
3004 ]);
3005 } 3001 }
3006 } 3002 }
3007 kind = ParameterKind.REQUIRED; 3003 kind = ParameterKind.REQUIRED;
3008 } 3004 }
3009 } while (!_matches(TokenType.CLOSE_PAREN) && 3005 } while (!_matches(TokenType.CLOSE_PAREN) &&
3010 !identical(initialToken, _currentToken)); 3006 !identical(initialToken, _currentToken));
3011 Token rightParenthesis = _expect(TokenType.CLOSE_PAREN); 3007 Token rightParenthesis = _expect(TokenType.CLOSE_PAREN);
3012 // 3008 //
3013 // Check that the groups were closed correctly. 3009 // Check that the groups were closed correctly.
3014 // 3010 //
(...skipping 1346 matching lines...) Expand 10 before | Expand all | Expand 10 after
4361 try { 4357 try {
4362 Expression index = parseExpression2(); 4358 Expression index = parseExpression2();
4363 Token rightBracket = _expect(TokenType.CLOSE_SQUARE_BRACKET); 4359 Token rightBracket = _expect(TokenType.CLOSE_SQUARE_BRACKET);
4364 expression = new IndexExpression.forCascade( 4360 expression = new IndexExpression.forCascade(
4365 period, leftBracket, index, rightBracket); 4361 period, leftBracket, index, rightBracket);
4366 period = null; 4362 period = null;
4367 } finally { 4363 } finally {
4368 _inInitializer = wasInInitializer; 4364 _inInitializer = wasInInitializer;
4369 } 4365 }
4370 } else { 4366 } else {
4371 _reportErrorForToken(ParserErrorCode.MISSING_IDENTIFIER, _currentToken, [ 4367 _reportErrorForToken(ParserErrorCode.MISSING_IDENTIFIER, _currentToken,
4372 _currentToken.lexeme 4368 [_currentToken.lexeme]);
4373 ]);
4374 functionName = _createSyntheticIdentifier(); 4369 functionName = _createSyntheticIdentifier();
4375 } 4370 }
4376 assert((expression == null && functionName != null) || 4371 assert((expression == null && functionName != null) ||
4377 (expression != null && functionName == null)); 4372 (expression != null && functionName == null));
4378 if (_currentToken.type == TokenType.OPEN_PAREN) { 4373 if (_currentToken.type == TokenType.OPEN_PAREN) {
4379 while (_currentToken.type == TokenType.OPEN_PAREN) { 4374 while (_currentToken.type == TokenType.OPEN_PAREN) {
4380 if (functionName != null) { 4375 if (functionName != null) {
4381 expression = new MethodInvocation( 4376 expression = new MethodInvocation(
4382 expression, period, functionName, parseArgumentList()); 4377 expression, period, functionName, parseArgumentList());
4383 period = null; 4378 period = null;
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
4555 */ 4550 */
4556 List<ClassMember> _parseClassMembers(String className, Token closingBracket) { 4551 List<ClassMember> _parseClassMembers(String className, Token closingBracket) {
4557 List<ClassMember> members = new List<ClassMember>(); 4552 List<ClassMember> members = new List<ClassMember>();
4558 Token memberStart = _currentToken; 4553 Token memberStart = _currentToken;
4559 while (!_matches(TokenType.EOF) && 4554 while (!_matches(TokenType.EOF) &&
4560 !_matches(TokenType.CLOSE_CURLY_BRACKET) && 4555 !_matches(TokenType.CLOSE_CURLY_BRACKET) &&
4561 (closingBracket != null || 4556 (closingBracket != null ||
4562 (!_matchesKeyword(Keyword.CLASS) && 4557 (!_matchesKeyword(Keyword.CLASS) &&
4563 !_matchesKeyword(Keyword.TYPEDEF)))) { 4558 !_matchesKeyword(Keyword.TYPEDEF)))) {
4564 if (_matches(TokenType.SEMICOLON)) { 4559 if (_matches(TokenType.SEMICOLON)) {
4565 _reportErrorForToken(ParserErrorCode.UNEXPECTED_TOKEN, _currentToken, [ 4560 _reportErrorForToken(ParserErrorCode.UNEXPECTED_TOKEN, _currentToken,
4566 _currentToken.lexeme 4561 [_currentToken.lexeme]);
4567 ]);
4568 _advance(); 4562 _advance();
4569 } else { 4563 } else {
4570 ClassMember member = parseClassMember(className); 4564 ClassMember member = parseClassMember(className);
4571 if (member != null) { 4565 if (member != null) {
4572 members.add(member); 4566 members.add(member);
4573 } 4567 }
4574 } 4568 }
4575 if (identical(_currentToken, memberStart)) { 4569 if (identical(_currentToken, memberStart)) {
4576 _reportErrorForToken(ParserErrorCode.UNEXPECTED_TOKEN, _currentToken, [ 4570 _reportErrorForToken(ParserErrorCode.UNEXPECTED_TOKEN, _currentToken,
4577 _currentToken.lexeme 4571 [_currentToken.lexeme]);
4578 ]);
4579 _advance(); 4572 _advance();
4580 } 4573 }
4581 memberStart = _currentToken; 4574 memberStart = _currentToken;
4582 } 4575 }
4583 return members; 4576 return members;
4584 } 4577 }
4585 4578
4586 /** 4579 /**
4587 * Parse a class type alias. The [commentAndMetadata] is the metadata to be 4580 * Parse a class type alias. The [commentAndMetadata] is the metadata to be
4588 * associated with the member. The [abstractKeyword] is the token representing 4581 * associated with the member. The [abstractKeyword] is the token representing
(...skipping 955 matching lines...) Expand 10 before | Expand all | Expand 10 after
5544 DeclaredIdentifier loopVariable = null; 5537 DeclaredIdentifier loopVariable = null;
5545 SimpleIdentifier identifier = null; 5538 SimpleIdentifier identifier = null;
5546 if (variableList == null) { 5539 if (variableList == null) {
5547 // We found: <expression> 'in' 5540 // We found: <expression> 'in'
5548 _reportErrorForCurrentToken( 5541 _reportErrorForCurrentToken(
5549 ParserErrorCode.MISSING_VARIABLE_IN_FOR_EACH); 5542 ParserErrorCode.MISSING_VARIABLE_IN_FOR_EACH);
5550 } else { 5543 } else {
5551 NodeList<VariableDeclaration> variables = variableList.variables; 5544 NodeList<VariableDeclaration> variables = variableList.variables;
5552 if (variables.length > 1) { 5545 if (variables.length > 1) {
5553 _reportErrorForCurrentToken( 5546 _reportErrorForCurrentToken(
5554 ParserErrorCode.MULTIPLE_VARIABLES_IN_FOR_EACH, [ 5547 ParserErrorCode.MULTIPLE_VARIABLES_IN_FOR_EACH,
5555 variables.length.toString() 5548 [variables.length.toString()]);
5556 ]);
5557 } 5549 }
5558 VariableDeclaration variable = variables[0]; 5550 VariableDeclaration variable = variables[0];
5559 if (variable.initializer != null) { 5551 if (variable.initializer != null) {
5560 _reportErrorForCurrentToken( 5552 _reportErrorForCurrentToken(
5561 ParserErrorCode.INITIALIZED_VARIABLE_IN_FOR_EACH); 5553 ParserErrorCode.INITIALIZED_VARIABLE_IN_FOR_EACH);
5562 } 5554 }
5563 Token keyword = variableList.keyword; 5555 Token keyword = variableList.keyword;
5564 TypeName type = variableList.type; 5556 TypeName type = variableList.type;
5565 if (keyword != null || type != null) { 5557 if (keyword != null || type != null) {
5566 loopVariable = new DeclaredIdentifier(commentAndMetadata.comment, 5558 loopVariable = new DeclaredIdentifier(commentAndMetadata.comment,
(...skipping 1025 matching lines...) Expand 10 before | Expand all | Expand 10 after
6592 if (!_currentToken.isUserDefinableOperator) { 6584 if (!_currentToken.isUserDefinableOperator) {
6593 _reportErrorForCurrentToken( 6585 _reportErrorForCurrentToken(
6594 ParserErrorCode.NON_USER_DEFINABLE_OPERATOR, [_currentToken.lexeme]); 6586 ParserErrorCode.NON_USER_DEFINABLE_OPERATOR, [_currentToken.lexeme]);
6595 } 6587 }
6596 SimpleIdentifier name = new SimpleIdentifier(getAndAdvance()); 6588 SimpleIdentifier name = new SimpleIdentifier(getAndAdvance());
6597 if (_matches(TokenType.EQ)) { 6589 if (_matches(TokenType.EQ)) {
6598 Token previous = _currentToken.previous; 6590 Token previous = _currentToken.previous;
6599 if ((_tokenMatches(previous, TokenType.EQ_EQ) || 6591 if ((_tokenMatches(previous, TokenType.EQ_EQ) ||
6600 _tokenMatches(previous, TokenType.BANG_EQ)) && 6592 _tokenMatches(previous, TokenType.BANG_EQ)) &&
6601 _currentToken.offset == previous.offset + 2) { 6593 _currentToken.offset == previous.offset + 2) {
6602 _reportErrorForCurrentToken(ParserErrorCode.INVALID_OPERATOR, [ 6594 _reportErrorForCurrentToken(ParserErrorCode.INVALID_OPERATOR,
6603 "${previous.lexeme}${_currentToken.lexeme}" 6595 ["${previous.lexeme}${_currentToken.lexeme}"]);
6604 ]);
6605 _advance(); 6596 _advance();
6606 } 6597 }
6607 } 6598 }
6608 FormalParameterList parameters = parseFormalParameterList(); 6599 FormalParameterList parameters = parseFormalParameterList();
6609 _validateFormalParameterList(parameters); 6600 _validateFormalParameterList(parameters);
6610 FunctionBody body = 6601 FunctionBody body =
6611 _parseFunctionBody(true, ParserErrorCode.MISSING_FUNCTION_BODY, false); 6602 _parseFunctionBody(true, ParserErrorCode.MISSING_FUNCTION_BODY, false);
6612 if (externalKeyword != null && body is! EmptyFunctionBody) { 6603 if (externalKeyword != null && body is! EmptyFunctionBody) {
6613 _reportErrorForCurrentToken(ParserErrorCode.EXTERNAL_OPERATOR_WITH_BODY); 6604 _reportErrorForCurrentToken(ParserErrorCode.EXTERNAL_OPERATOR_WITH_BODY);
6614 } 6605 }
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after
6982 * statement* 6973 * statement*
6983 */ 6974 */
6984 List<Statement> _parseStatementList() { 6975 List<Statement> _parseStatementList() {
6985 List<Statement> statements = new List<Statement>(); 6976 List<Statement> statements = new List<Statement>();
6986 Token statementStart = _currentToken; 6977 Token statementStart = _currentToken;
6987 while (!_matches(TokenType.EOF) && 6978 while (!_matches(TokenType.EOF) &&
6988 !_matches(TokenType.CLOSE_CURLY_BRACKET) && 6979 !_matches(TokenType.CLOSE_CURLY_BRACKET) &&
6989 !_isSwitchMember()) { 6980 !_isSwitchMember()) {
6990 statements.add(parseStatement2()); 6981 statements.add(parseStatement2());
6991 if (identical(_currentToken, statementStart)) { 6982 if (identical(_currentToken, statementStart)) {
6992 _reportErrorForToken(ParserErrorCode.UNEXPECTED_TOKEN, _currentToken, [ 6983 _reportErrorForToken(ParserErrorCode.UNEXPECTED_TOKEN, _currentToken,
6993 _currentToken.lexeme 6984 [_currentToken.lexeme]);
6994 ]);
6995 _advance(); 6985 _advance();
6996 } 6986 }
6997 statementStart = _currentToken; 6987 statementStart = _currentToken;
6998 } 6988 }
6999 return statements; 6989 return statements;
7000 } 6990 }
7001 6991
7002 /** 6992 /**
7003 * Parse a string literal that contains interpolations. Return the string 6993 * Parse a string literal that contains interpolations. Return the string
7004 * literal that was parsed. 6994 * literal that was parsed.
(...skipping 1216 matching lines...) Expand 10 before | Expand all | Expand 10 after
8221 int secondDigit = lexeme.codeUnitAt(currentIndex + 1); 8211 int secondDigit = lexeme.codeUnitAt(currentIndex + 1);
8222 int thirdDigit = lexeme.codeUnitAt(currentIndex + 2); 8212 int thirdDigit = lexeme.codeUnitAt(currentIndex + 2);
8223 int fourthDigit = lexeme.codeUnitAt(currentIndex + 3); 8213 int fourthDigit = lexeme.codeUnitAt(currentIndex + 3);
8224 if (!_isHexDigit(firstDigit) || 8214 if (!_isHexDigit(firstDigit) ||
8225 !_isHexDigit(secondDigit) || 8215 !_isHexDigit(secondDigit) ||
8226 !_isHexDigit(thirdDigit) || 8216 !_isHexDigit(thirdDigit) ||
8227 !_isHexDigit(fourthDigit)) { 8217 !_isHexDigit(fourthDigit)) {
8228 // Illegal escape sequence: invalid hex digits 8218 // Illegal escape sequence: invalid hex digits
8229 _reportErrorForCurrentToken(ParserErrorCode.INVALID_UNICODE_ESCAPE); 8219 _reportErrorForCurrentToken(ParserErrorCode.INVALID_UNICODE_ESCAPE);
8230 } else { 8220 } else {
8231 _appendScalarValue(buffer, lexeme.substring(index, currentIndex + 1), 8221 _appendScalarValue(
8222 buffer,
8223 lexeme
8224 .substring(
8225 index,
8226 currentIndex + 1),
8232 (((((Character.digit(firstDigit, 16) << 4) + 8227 (((((Character.digit(firstDigit, 16) << 4) +
8233 Character.digit(secondDigit, 16)) << 8228 Character.digit(secondDigit, 16)) <<
8234 4) + 8229 4) +
8235 Character.digit(thirdDigit, 16)) << 8230 Character.digit(thirdDigit, 16)) <<
8236 4) + 8231 4) +
8237 Character.digit(fourthDigit, 16), index, currentIndex + 3); 8232 Character
8233 .digit(fourthDigit, 16),
8234 index,
8235 currentIndex +
8236 3);
8238 } 8237 }
8239 return currentIndex + 4; 8238 return currentIndex + 4;
8240 } 8239 }
8241 } else { 8240 } else {
8242 buffer.writeCharCode(currentChar); 8241 buffer.writeCharCode(currentChar);
8243 } 8242 }
8244 return currentIndex + 1; 8243 return currentIndex + 1;
8245 } 8244 }
8246 8245
8247 /** 8246 /**
(...skipping 2284 matching lines...) Expand 10 before | Expand all | Expand 10 after
10532 } 10531 }
10533 10532
10534 /** 10533 /**
10535 * Copy resolution data from the [fromNode] to the [toNode]. 10534 * Copy resolution data from the [fromNode] to the [toNode].
10536 */ 10535 */
10537 static void copyResolutionData(AstNode fromNode, AstNode toNode) { 10536 static void copyResolutionData(AstNode fromNode, AstNode toNode) {
10538 ResolutionCopier copier = new ResolutionCopier(); 10537 ResolutionCopier copier = new ResolutionCopier();
10539 copier._isEqualNodes(fromNode, toNode); 10538 copier._isEqualNodes(fromNode, toNode);
10540 } 10539 }
10541 } 10540 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/generated/incremental_resolver.dart ('k') | pkg/analyzer/lib/src/generated/resolver.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698