| 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 fcf9b0132a2d4265d7527c05f679a4c09e57fd81..d3f747517b61ae2e1f002434f72d482c97e7f9f7 100644
|
| --- a/pkg/analyzer/lib/src/generated/parser.dart
|
| +++ b/pkg/analyzer/lib/src/generated/parser.dart
|
| @@ -2135,6 +2135,12 @@ class Parser {
|
| int _errorListenerLock = 0;
|
|
|
| /**
|
| + * A flag indicating whether the parser is to parse asserts in the initializer
|
| + * list of a constructor.
|
| + */
|
| + bool _enableAssertInitializer = false;
|
| +
|
| + /**
|
| * A flag indicating whether the parser is to parse the async support.
|
| */
|
| bool _parseAsync = true;
|
| @@ -2202,6 +2208,20 @@ class Parser {
|
| }
|
|
|
| /**
|
| + * Return `true` if the parser is to parse asserts in the initializer list of
|
| + * a constructor.
|
| + */
|
| + bool get enableAssertInitializer => _enableAssertInitializer;
|
| +
|
| + /**
|
| + * Set whether the parser is to parse asserts in the initializer list of a
|
| + * constructor to match the given [enable] flag.
|
| + */
|
| + void set enableAssertInitializer(bool enable) {
|
| + _enableAssertInitializer = enable;
|
| + }
|
| +
|
| + /**
|
| * Return `true` if the current token is the first token of a return type that
|
| * is followed by an identifier, possibly followed by a list of type
|
| * parameters, followed by a left-parenthesis. This is used by
|
| @@ -2862,6 +2882,7 @@ class Parser {
|
| "parseDirective invoked in an invalid state (currentToken = $_currentToken)");
|
| }
|
| }
|
| +
|
| Directive directive = parseDirective();
|
| if (declarations.length > 0 && !directiveFoundAfterDeclaration) {
|
| _reportErrorForToken(ParserErrorCode.DIRECTIVE_AFTER_DECLARATION,
|
| @@ -4346,6 +4367,31 @@ class Parser {
|
| }
|
|
|
| /**
|
| + * Parse an assert within a constructor's initializer list. Return the assert.
|
| + *
|
| + * This method assumes that the current token matches `Keyword.ASSERT`.
|
| + *
|
| + * assertInitializer ::=
|
| + * 'assert' '(' expression [',' expression] ')'
|
| + */
|
| + void _parseAssertInitializer() {
|
| + // TODO(brianwilkerson) Capture the syntax in the AST using a new class,
|
| + // such as AssertInitializer
|
| + Token keyword = getAndAdvance();
|
| + Token leftParen = _expect(TokenType.OPEN_PAREN);
|
| + Expression expression = parseExpression2();
|
| + Token comma;
|
| + Expression message;
|
| + if (_matches(TokenType.COMMA)) {
|
| + comma = getAndAdvance();
|
| + message = parseExpression2();
|
| + }
|
| + Token rightParen = _expect(TokenType.CLOSE_PAREN);
|
| +// return new AssertInitializer(
|
| +// keyword, leftParen, expression, comma, message, rightParen);
|
| + }
|
| +
|
| + /**
|
| * Parse an assert statement. Return the assert statement.
|
| *
|
| * This method assumes that the current token matches `Keyword.ASSERT`.
|
| @@ -5502,6 +5548,9 @@ class Parser {
|
| } else if (_matches(TokenType.OPEN_CURLY_BRACKET) ||
|
| _matches(TokenType.FUNCTION)) {
|
| _reportErrorForCurrentToken(ParserErrorCode.MISSING_INITIALIZER);
|
| + } else if (_enableAssertInitializer &&
|
| + _matchesKeyword(Keyword.ASSERT)) {
|
| + _parseAssertInitializer();
|
| } else {
|
| initializers.add(_parseConstructorFieldInitializer(false));
|
| }
|
| @@ -8282,6 +8331,7 @@ class Parser {
|
| Keyword keyword = _currentToken.keyword;
|
| return keyword == Keyword.CASE || keyword == Keyword.DEFAULT;
|
| }
|
| +
|
| while (!atEndOrNextMember()) {
|
| _advance();
|
| }
|
| @@ -8625,6 +8675,7 @@ class Parser {
|
| type == TokenType.INT ||
|
| type == TokenType.DOUBLE;
|
| }
|
| +
|
| while ((_tokenMatchesIdentifier(token) && !isKeywordAfterUri(token)) ||
|
| isValidInUri(token)) {
|
| token = token.next;
|
|
|