Chromium Code Reviews| 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 library analyzer.src.generated.parser; | 5 library analyzer.src.generated.parser; |
| 6 | 6 |
| 7 import 'dart:collection'; | 7 import 'dart:collection'; |
| 8 import "dart:math" as math; | 8 import "dart:math" as math; |
| 9 | 9 |
| 10 import 'package:analyzer/src/generated/ast.dart'; | 10 import 'package:analyzer/src/generated/ast.dart'; |
| (...skipping 6083 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6094 } | 6094 } |
| 6095 return new NativeFunctionBody( | 6095 return new NativeFunctionBody( |
| 6096 nativeToken, stringLiteral, _expect(TokenType.SEMICOLON)); | 6096 nativeToken, stringLiteral, _expect(TokenType.SEMICOLON)); |
| 6097 } | 6097 } |
| 6098 Token keyword = null; | 6098 Token keyword = null; |
| 6099 Token star = null; | 6099 Token star = null; |
| 6100 if (_matchesString(ASYNC)) { | 6100 if (_matchesString(ASYNC)) { |
| 6101 keyword = getAndAdvance(); | 6101 keyword = getAndAdvance(); |
| 6102 if (!_parseAsync) { | 6102 if (!_parseAsync) { |
| 6103 _reportErrorForToken(ParserErrorCode.ASYNC_NOT_SUPPORTED, keyword); | 6103 _reportErrorForToken(ParserErrorCode.ASYNC_NOT_SUPPORTED, keyword); |
| 6104 keyword = null; | |
|
Brian Wilkerson
2016/01/13 21:38:01
I don't think we want to make these changes to the
danrubel
2016/01/13 22:02:20
Yes. There are a number of places in the resolver
| |
| 6104 } | 6105 } |
| 6105 if (_matches(TokenType.STAR)) { | 6106 if (_matches(TokenType.STAR)) { |
| 6106 star = getAndAdvance(); | 6107 star = getAndAdvance(); |
| 6108 if (!_parseAsync) { | |
| 6109 star = null; | |
| 6110 } | |
| 6107 _inGenerator = true; | 6111 _inGenerator = true; |
| 6108 } | 6112 } |
| 6109 _inAsync = true; | 6113 _inAsync = true; |
| 6110 } else if (_matchesString(SYNC)) { | 6114 } else if (_matchesString(SYNC)) { |
| 6111 keyword = getAndAdvance(); | 6115 keyword = getAndAdvance(); |
| 6112 if (!_parseAsync) { | 6116 if (!_parseAsync) { |
| 6113 _reportErrorForToken(ParserErrorCode.ASYNC_NOT_SUPPORTED, keyword); | 6117 _reportErrorForToken(ParserErrorCode.ASYNC_NOT_SUPPORTED, keyword); |
| 6118 keyword = null; | |
| 6114 } | 6119 } |
| 6115 if (_matches(TokenType.STAR)) { | 6120 if (_matches(TokenType.STAR)) { |
| 6116 star = getAndAdvance(); | 6121 star = getAndAdvance(); |
| 6122 if (!_parseAsync) { | |
| 6123 star = null; | |
| 6124 } | |
| 6117 _inGenerator = true; | 6125 _inGenerator = true; |
| 6118 } | 6126 } |
| 6119 } | 6127 } |
| 6120 if (_matches(TokenType.FUNCTION)) { | 6128 if (_matches(TokenType.FUNCTION)) { |
| 6121 if (keyword != null) { | 6129 if (keyword != null) { |
| 6122 if (!_tokenMatchesString(keyword, ASYNC)) { | 6130 if (!_tokenMatchesString(keyword, ASYNC)) { |
| 6123 _reportErrorForToken(ParserErrorCode.INVALID_SYNC, keyword); | 6131 _reportErrorForToken(ParserErrorCode.INVALID_SYNC, keyword); |
| 6124 keyword = null; | 6132 keyword = null; |
| 6125 } else if (star != null) { | 6133 } else if (star != null) { |
| 6126 _reportErrorForToken( | 6134 _reportErrorForToken( |
| (...skipping 3247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 9374 * identifiers async, await, or yield is used as an identifier in a function | 9382 * identifiers async, await, or yield is used as an identifier in a function |
| 9375 * body marked with either async, async*, or sync*. | 9383 * body marked with either async, async*, or sync*. |
| 9376 */ | 9384 */ |
| 9377 static const ParserErrorCode ASYNC_KEYWORD_USED_AS_IDENTIFIER = | 9385 static const ParserErrorCode ASYNC_KEYWORD_USED_AS_IDENTIFIER = |
| 9378 const ParserErrorCode('ASYNC_KEYWORD_USED_AS_IDENTIFIER', | 9386 const ParserErrorCode('ASYNC_KEYWORD_USED_AS_IDENTIFIER', |
| 9379 "The keywords 'async', 'await', and 'yield' may not be used as identif iers in an asynchronous or generator function."); | 9387 "The keywords 'async', 'await', and 'yield' may not be used as identif iers in an asynchronous or generator function."); |
| 9380 | 9388 |
| 9381 /** | 9389 /** |
| 9382 * Some environments, such as Fletch, do not support async. | 9390 * Some environments, such as Fletch, do not support async. |
| 9383 */ | 9391 */ |
| 9384 static const CompileTimeErrorCode ASYNC_NOT_SUPPORTED = | 9392 static const ParserErrorCode ASYNC_NOT_SUPPORTED = |
| 9385 const CompileTimeErrorCode('ASYNC_NOT_SUPPORTED', | 9393 const ParserErrorCode('ASYNC_NOT_SUPPORTED', |
| 9386 "Async and sync are not supported in this environment."); | 9394 "Async and sync are not supported in this environment."); |
| 9387 | 9395 |
| 9388 static const ParserErrorCode BREAK_OUTSIDE_OF_LOOP = const ParserErrorCode( | 9396 static const ParserErrorCode BREAK_OUTSIDE_OF_LOOP = const ParserErrorCode( |
| 9389 'BREAK_OUTSIDE_OF_LOOP', | 9397 'BREAK_OUTSIDE_OF_LOOP', |
| 9390 "A break statement cannot be used outside of a loop or switch statement"); | 9398 "A break statement cannot be used outside of a loop or switch statement"); |
| 9391 | 9399 |
| 9392 static const ParserErrorCode CLASS_IN_CLASS = const ParserErrorCode( | 9400 static const ParserErrorCode CLASS_IN_CLASS = const ParserErrorCode( |
| 9393 'CLASS_IN_CLASS', "Classes cannot be declared inside other classes"); | 9401 'CLASS_IN_CLASS', "Classes cannot be declared inside other classes"); |
| 9394 | 9402 |
| 9395 static const ParserErrorCode COLON_IN_PLACE_OF_IN = const ParserErrorCode( | 9403 static const ParserErrorCode COLON_IN_PLACE_OF_IN = const ParserErrorCode( |
| (...skipping 1960 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 11356 } | 11364 } |
| 11357 | 11365 |
| 11358 /** | 11366 /** |
| 11359 * Copy resolution data from the [fromNode] to the [toNode]. | 11367 * Copy resolution data from the [fromNode] to the [toNode]. |
| 11360 */ | 11368 */ |
| 11361 static void copyResolutionData(AstNode fromNode, AstNode toNode) { | 11369 static void copyResolutionData(AstNode fromNode, AstNode toNode) { |
| 11362 ResolutionCopier copier = new ResolutionCopier(); | 11370 ResolutionCopier copier = new ResolutionCopier(); |
| 11363 copier._isEqualNodes(fromNode, toNode); | 11371 copier._isEqualNodes(fromNode, toNode); |
| 11364 } | 11372 } |
| 11365 } | 11373 } |
| OLD | NEW |