mirror of
https://github.com/dart-lang/sdk
synced 2024-09-16 04:16:51 +00:00
Add fasta parser argument list recovery
Change-Id: Ic45e95a130eb01f6bd8d390607e2b110bc8f9d99 Reviewed-on: https://dart-review.googlesource.com/22760 Reviewed-by: Brian Wilkerson <brianwilkerson@google.com> Commit-Queue: Dan Rubel <danrubel@google.com>
This commit is contained in:
parent
37cd5e33ce
commit
bac8cf868c
|
@ -357,14 +357,6 @@ class ErrorParserTest_Fasta extends FastaParserTestCase
|
|||
super.test_expectedStringLiteral();
|
||||
}
|
||||
|
||||
@override
|
||||
@failingTest
|
||||
void test_expectedToken_commaMissingInArgumentList() {
|
||||
// TODO(brianwilkerson) Wrong errors:
|
||||
// Expected 1 errors of type ParserErrorCode.EXPECTED_TOKEN, found 0
|
||||
super.test_expectedToken_commaMissingInArgumentList();
|
||||
}
|
||||
|
||||
@override
|
||||
@failingTest
|
||||
void test_expectedToken_parseStatement_afterVoid() {
|
||||
|
@ -2891,13 +2883,6 @@ class RecoveryParserTest_Fasta extends FastaParserTestCase
|
|||
super.test_keywordInPlaceOfIdentifier();
|
||||
}
|
||||
|
||||
@override
|
||||
@failingTest
|
||||
void test_missing_commaInArgumentList() {
|
||||
// TODO(brianwilkerson) reportUnrecoverableErrorWithToken
|
||||
super.test_missing_commaInArgumentList();
|
||||
}
|
||||
|
||||
@override
|
||||
@failingTest
|
||||
void test_missingComma_beforeNamedArgument() {
|
||||
|
|
|
@ -2894,8 +2894,9 @@ class Foo {
|
|||
createParser('(x, y z)');
|
||||
ArgumentList list = parser.parseArgumentList();
|
||||
expectNotNullIfNoErrors(list);
|
||||
listener
|
||||
.assertErrors([expectedError(ParserErrorCode.EXPECTED_TOKEN, 4, 1)]);
|
||||
listener.assertErrors(usingFastaParser
|
||||
? [expectedError(ParserErrorCode.UNEXPECTED_TOKEN, 6, 1)]
|
||||
: [expectedError(ParserErrorCode.EXPECTED_TOKEN, 4, 1)]);
|
||||
}
|
||||
|
||||
void test_expectedToken_parseStatement_afterVoid() {
|
||||
|
@ -10527,7 +10528,10 @@ class C<K {
|
|||
}
|
||||
|
||||
void test_missing_commaInArgumentList() {
|
||||
parseExpression("f(x: 1 y: 2)", codes: [ParserErrorCode.EXPECTED_TOKEN]);
|
||||
parseExpression("f(x: 1 y: 2)",
|
||||
codes: usingFastaParser
|
||||
? [ParserErrorCode.UNEXPECTED_TOKEN]
|
||||
: [ParserErrorCode.EXPECTED_TOKEN]);
|
||||
}
|
||||
|
||||
void test_missingComma_beforeNamedArgument() {
|
||||
|
|
|
@ -4965,7 +4965,7 @@ class Parser {
|
|||
bool hasSeenNamedArgument = false;
|
||||
bool old = mayParseFunctionExpressions;
|
||||
mayParseFunctionExpressions = true;
|
||||
do {
|
||||
while (true) {
|
||||
Token next = token.next;
|
||||
if (optional(')', next)) {
|
||||
token = next;
|
||||
|
@ -4982,13 +4982,20 @@ class Parser {
|
|||
// Positional argument after named argument.
|
||||
reportRecoverableError(next, fasta.messagePositionalAfterNamedArgument);
|
||||
}
|
||||
token = parseExpression(token.next).next;
|
||||
token = parseExpression(token.next);
|
||||
next = token.next;
|
||||
if (colon != null) listener.handleNamedArgument(colon);
|
||||
++argumentCount;
|
||||
} while (optional(',', token));
|
||||
if (optional(',', next)) {
|
||||
token = next;
|
||||
continue;
|
||||
}
|
||||
token = ensureCloseParen(token, begin);
|
||||
break;
|
||||
}
|
||||
assert(optional(')', token));
|
||||
mayParseFunctionExpressions = old;
|
||||
listener.endArguments(argumentCount, begin, token);
|
||||
expect(')', token);
|
||||
return token;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue