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

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

Issue 2282233002: Add support for parsing, but not capturing, assers in constructor initializer lists (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 4 years, 4 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 | « no previous file | pkg/analyzer/test/generated/parser_test.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 fcf9b0132a2d4265d7527c05f679a4c09e57fd81..8efed5534eb4ae140ece8435b1eea7d2f68eca33 100644
--- a/pkg/analyzer/lib/src/generated/parser.dart
+++ b/pkg/analyzer/lib/src/generated/parser.dart
@@ -2862,6 +2862,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 +4347,30 @@ 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() {
+ // return AssertInitializer
scheglov 2016/08/27 00:06:45 I don't quite understand what this comment means.
Brian Wilkerson 2016/08/27 00:32:44 Done It was a reminder to "Capture the syntax in
+ 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 +5527,8 @@ class Parser {
} else if (_matches(TokenType.OPEN_CURLY_BRACKET) ||
_matches(TokenType.FUNCTION)) {
_reportErrorForCurrentToken(ParserErrorCode.MISSING_INITIALIZER);
+ } else if (_matchesKeyword(Keyword.ASSERT)) {
+ _parseAssertInitializer();
} else {
initializers.add(_parseConstructorFieldInitializer(false));
}
@@ -8282,6 +8309,7 @@ class Parser {
Keyword keyword = _currentToken.keyword;
return keyword == Keyword.CASE || keyword == Keyword.DEFAULT;
}
+
while (!atEndOrNextMember()) {
_advance();
}
@@ -8625,6 +8653,7 @@ class Parser {
type == TokenType.INT ||
type == TokenType.DOUBLE;
}
+
while ((_tokenMatchesIdentifier(token) && !isKeywordAfterUri(token)) ||
isValidInUri(token)) {
token = token.next;
« no previous file with comments | « no previous file | pkg/analyzer/test/generated/parser_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698