Chromium Code Reviews| Index: pkg/analyzer/lib/src/generated/parser.dart |
| diff --git a/pkg/analyzer/lib/src/generated/parser.dart b/pkg/analyzer/lib/src/generated/parser.dart |
| index 33510ed07a8247196bc173ce794b9e16c4339dea..5720487ef0981d7469ca21e69586a6ada105488c 100644 |
| --- a/pkg/analyzer/lib/src/generated/parser.dart |
| +++ b/pkg/analyzer/lib/src/generated/parser.dart |
| @@ -2108,6 +2108,11 @@ class Parser { |
| int _errorListenerLock = 0; |
| /** |
| + * A flag indicating whether the parser is to parse the async support. |
| + */ |
| + bool _parseAsync = true; |
| + |
| + /** |
| * A flag indicating whether parser is to parse function bodies. |
| */ |
| bool _parseFunctionBodies = true; |
| @@ -2188,6 +2193,13 @@ class Parser { |
| } |
| /** |
| + * Set whether the parser is to parse the async support. |
| + */ |
| + void set parseAsync(bool parseAsync) { |
| + this._parseAsync = parseAsync; |
| + } |
| + |
| + /** |
| * Set whether parser is to parse function bodies. |
| */ |
| void set parseFunctionBodies(bool parseFunctionBodies) { |
| @@ -6087,6 +6099,9 @@ class Parser { |
| Token star = null; |
| if (_matchesString(ASYNC)) { |
| keyword = getAndAdvance(); |
| + if (!_parseAsync) { |
| + _reportErrorForToken(ParserErrorCode.ASYNC_NOT_SUPPORTED, keyword); |
| + } |
| if (_matches(TokenType.STAR)) { |
| star = getAndAdvance(); |
| _inGenerator = true; |
| @@ -6094,6 +6109,9 @@ class Parser { |
| _inAsync = true; |
| } else if (_matchesString(SYNC)) { |
| keyword = getAndAdvance(); |
| + if (!_parseAsync) { |
| + _reportErrorForToken(ParserErrorCode.ASYNC_NOT_SUPPORTED, keyword); |
| + } |
| if (_matches(TokenType.STAR)) { |
| star = getAndAdvance(); |
| _inGenerator = true; |
| @@ -9360,6 +9378,13 @@ class ParserErrorCode extends ErrorCode { |
| const ParserErrorCode('ASYNC_KEYWORD_USED_AS_IDENTIFIER', |
| "The keywords 'async', 'await', and 'yield' may not be used as identifiers in an asynchronous or generator function."); |
| + /** |
| + * Some environments such as fletch do not support async. |
|
Brian Wilkerson
2016/01/08 18:43:47
"fletch" or "Fletch"?
"environments such as fletc
danrubel
2016/01/08 20:45:51
Done.
|
| + */ |
| + static const CompileTimeErrorCode ASYNC_NOT_SUPPORTED = |
| + const CompileTimeErrorCode('ASYNC_NOT_SUPPORTED', |
| + "Async and sync are not supported in this environment."); |
|
Brian Wilkerson
2016/01/08 18:43:47
"in this environment" or "on this platform"? What
danrubel
2016/01/08 20:45:51
Really good question... I struggled with this as w
|
| + |
| static const ParserErrorCode BREAK_OUTSIDE_OF_LOOP = const ParserErrorCode( |
| 'BREAK_OUTSIDE_OF_LOOP', |
| "A break statement cannot be used outside of a loop or switch statement"); |