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

Unified Diff: pkg/analyzer/lib/src/generated/parser.dart

Issue 1570183002: add parser parseAsync flag (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: merge Created 4 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/analyzer/lib/src/generated/engine.dart ('k') | pkg/analyzer/lib/src/generated/utilities_general.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..de0306f68f7c9a3cc8eca99b9598f94f1bbd2b18 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.
+ */
+ static const CompileTimeErrorCode ASYNC_NOT_SUPPORTED =
+ const CompileTimeErrorCode('ASYNC_NOT_SUPPORTED',
+ "Async and sync are not supported in this environment.");
+
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");
« no previous file with comments | « pkg/analyzer/lib/src/generated/engine.dart ('k') | pkg/analyzer/lib/src/generated/utilities_general.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698