| OLD | NEW |
| 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 6354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6365 Token awaitKeyword = null; | 6365 Token awaitKeyword = null; |
| 6366 if (_matchesString(_AWAIT)) { | 6366 if (_matchesString(_AWAIT)) { |
| 6367 awaitKeyword = andAdvance; | 6367 awaitKeyword = andAdvance; |
| 6368 } | 6368 } |
| 6369 Token forKeyword = _expectKeyword(Keyword.FOR); | 6369 Token forKeyword = _expectKeyword(Keyword.FOR); |
| 6370 Token leftParenthesis = _expect(TokenType.OPEN_PAREN); | 6370 Token leftParenthesis = _expect(TokenType.OPEN_PAREN); |
| 6371 VariableDeclarationList variableList = null; | 6371 VariableDeclarationList variableList = null; |
| 6372 Expression initialization = null; | 6372 Expression initialization = null; |
| 6373 if (!_matches(TokenType.SEMICOLON)) { | 6373 if (!_matches(TokenType.SEMICOLON)) { |
| 6374 CommentAndMetadata commentAndMetadata = _parseCommentAndMetadata(); | 6374 CommentAndMetadata commentAndMetadata = _parseCommentAndMetadata(); |
| 6375 if (_matchesIdentifier() && _tokenMatchesKeyword(_peek(), Keyword.IN)) { | 6375 if (_matchesIdentifier() && (_tokenMatchesKeyword(_peek(), Keyword.IN) |
| _tokenMatches(_peek(), TokenType.COLON))) { |
| 6376 List<VariableDeclaration> variables = new List<VariableDeclaration>(); | 6376 List<VariableDeclaration> variables = new List<VariableDeclaration>(); |
| 6377 SimpleIdentifier variableName = parseSimpleIdentifier(); | 6377 SimpleIdentifier variableName = parseSimpleIdentifier(); |
| 6378 variables.add( | 6378 variables.add( |
| 6379 new VariableDeclaration(null, null, variableName, null, null)); | 6379 new VariableDeclaration(null, null, variableName, null, null)); |
| 6380 variableList = new VariableDeclarationList( | 6380 variableList = new VariableDeclarationList( |
| 6381 commentAndMetadata.comment, | 6381 commentAndMetadata.comment, |
| 6382 commentAndMetadata.metadata, | 6382 commentAndMetadata.metadata, |
| 6383 null, | 6383 null, |
| 6384 null, | 6384 null, |
| 6385 variables); | 6385 variables); |
| 6386 } else if (_isInitializedVariableDeclaration()) { | 6386 } else if (_isInitializedVariableDeclaration()) { |
| 6387 variableList = | 6387 variableList = |
| 6388 _parseVariableDeclarationListAfterMetadata(commentAndMetadata); | 6388 _parseVariableDeclarationListAfterMetadata(commentAndMetadata); |
| 6389 } else { | 6389 } else { |
| 6390 initialization = parseExpression2(); | 6390 initialization = parseExpression2(); |
| 6391 } | 6391 } |
| 6392 if (_matchesKeyword(Keyword.IN)) { | 6392 if (_matchesKeyword(Keyword.IN) || _matches(TokenType.COLON)) { |
| 6393 if (_matches(TokenType.COLON)) { |
| 6394 _reportErrorForCurrentToken(ParserErrorCode.COLON_IN_PLACE_OF_IN); |
| 6395 } |
| 6393 DeclaredIdentifier loopVariable = null; | 6396 DeclaredIdentifier loopVariable = null; |
| 6394 SimpleIdentifier identifier = null; | 6397 SimpleIdentifier identifier = null; |
| 6395 if (variableList == null) { | 6398 if (variableList == null) { |
| 6396 // We found: <expression> 'in' | 6399 // We found: <expression> 'in' |
| 6397 _reportErrorForCurrentToken( | 6400 _reportErrorForCurrentToken( |
| 6398 ParserErrorCode.MISSING_VARIABLE_IN_FOR_EACH); | 6401 ParserErrorCode.MISSING_VARIABLE_IN_FOR_EACH); |
| 6399 } else { | 6402 } else { |
| 6400 NodeList<VariableDeclaration> variables = variableList.variables; | 6403 NodeList<VariableDeclaration> variables = variableList.variables; |
| 6401 if (variables.length > 1) { | 6404 if (variables.length > 1) { |
| 6402 _reportErrorForCurrentToken( | 6405 _reportErrorForCurrentToken( |
| (...skipping 16 matching lines...) Expand all Loading... |
| 6419 variable.name); | 6422 variable.name); |
| 6420 } else { | 6423 } else { |
| 6421 if (!commentAndMetadata.metadata.isEmpty) { | 6424 if (!commentAndMetadata.metadata.isEmpty) { |
| 6422 // TODO(jwren) metadata isn't allowed before the identifier in | 6425 // TODO(jwren) metadata isn't allowed before the identifier in |
| 6423 // "identifier in expression", add warning if commentAndMetadata | 6426 // "identifier in expression", add warning if commentAndMetadata |
| 6424 // has content | 6427 // has content |
| 6425 } | 6428 } |
| 6426 identifier = variable.name; | 6429 identifier = variable.name; |
| 6427 } | 6430 } |
| 6428 } | 6431 } |
| 6429 Token inKeyword = _expectKeyword(Keyword.IN); | 6432 Token inKeyword = andAdvance; |
| 6430 Expression iterator = parseExpression2(); | 6433 Expression iterator = parseExpression2(); |
| 6431 Token rightParenthesis = _expect(TokenType.CLOSE_PAREN); | 6434 Token rightParenthesis = _expect(TokenType.CLOSE_PAREN); |
| 6432 Statement body = parseStatement2(); | 6435 Statement body = parseStatement2(); |
| 6433 if (loopVariable == null) { | 6436 if (loopVariable == null) { |
| 6434 return new ForEachStatement.con2( | 6437 return new ForEachStatement.con2( |
| 6435 awaitKeyword, | 6438 awaitKeyword, |
| 6436 forKeyword, | 6439 forKeyword, |
| 6437 leftParenthesis, | 6440 leftParenthesis, |
| 6438 identifier, | 6441 identifier, |
| 6439 inKeyword, | 6442 inKeyword, |
| (...skipping 3638 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10078 | 10081 |
| 10079 static const ParserErrorCode ASSERT_DOES_NOT_TAKE_RETHROW = | 10082 static const ParserErrorCode ASSERT_DOES_NOT_TAKE_RETHROW = |
| 10080 const ParserErrorCode( | 10083 const ParserErrorCode( |
| 10081 'ASSERT_DOES_NOT_TAKE_RETHROW', | 10084 'ASSERT_DOES_NOT_TAKE_RETHROW', |
| 10082 "Assert cannot be called on rethrows"); | 10085 "Assert cannot be called on rethrows"); |
| 10083 | 10086 |
| 10084 static const ParserErrorCode BREAK_OUTSIDE_OF_LOOP = const ParserErrorCode( | 10087 static const ParserErrorCode BREAK_OUTSIDE_OF_LOOP = const ParserErrorCode( |
| 10085 'BREAK_OUTSIDE_OF_LOOP', | 10088 'BREAK_OUTSIDE_OF_LOOP', |
| 10086 "A break statement cannot be used outside of a loop or switch statement"); | 10089 "A break statement cannot be used outside of a loop or switch statement"); |
| 10087 | 10090 |
| 10091 static const ParserErrorCode COLON_IN_PLACE_OF_IN = const ParserErrorCode( |
| 10092 'COLON_IN_PLACE_OF_IN', |
| 10093 "For-in loops use 'in' rather than a colon"); |
| 10094 |
| 10088 static const ParserErrorCode CONST_AND_FINAL = const ParserErrorCode( | 10095 static const ParserErrorCode CONST_AND_FINAL = const ParserErrorCode( |
| 10089 'CONST_AND_FINAL', | 10096 'CONST_AND_FINAL', |
| 10090 "Members cannot be declared to be both 'const' and 'final'"); | 10097 "Members cannot be declared to be both 'const' and 'final'"); |
| 10091 | 10098 |
| 10092 static const ParserErrorCode CONST_AND_VAR = const ParserErrorCode( | 10099 static const ParserErrorCode CONST_AND_VAR = const ParserErrorCode( |
| 10093 'CONST_AND_VAR', | 10100 'CONST_AND_VAR', |
| 10094 "Members cannot be declared to be both 'const' and 'var'"); | 10101 "Members cannot be declared to be both 'const' and 'var'"); |
| 10095 | 10102 |
| 10096 static const ParserErrorCode CONST_CLASS = const ParserErrorCode( | 10103 static const ParserErrorCode CONST_CLASS = const ParserErrorCode( |
| 10097 'CONST_CLASS', | 10104 'CONST_CLASS', |
| (...skipping 2029 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12127 * Copy resolution data from one node to another. | 12134 * Copy resolution data from one node to another. |
| 12128 * | 12135 * |
| 12129 * @param fromNode the node from which resolution information will be copied | 12136 * @param fromNode the node from which resolution information will be copied |
| 12130 * @param toNode the node to which resolution information will be copied | 12137 * @param toNode the node to which resolution information will be copied |
| 12131 */ | 12138 */ |
| 12132 static void copyResolutionData(AstNode fromNode, AstNode toNode) { | 12139 static void copyResolutionData(AstNode fromNode, AstNode toNode) { |
| 12133 ResolutionCopier copier = new ResolutionCopier(); | 12140 ResolutionCopier copier = new ResolutionCopier(); |
| 12134 copier._isEqualNodes(fromNode, toNode); | 12141 copier._isEqualNodes(fromNode, toNode); |
| 12135 } | 12142 } |
| 12136 } | 12143 } |
| OLD | NEW |