-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for
...
inside map patterns
Bug: #50035 Change-Id: I350eb526e67e4cc42c94b4776e5d38315932ddc5 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/272382 Reviewed-by: Konstantin Shcheglov <scheglov@google.com> Commit-Queue: Paul Berry <paulberry@google.com>
- Loading branch information
1 parent
eaff33f
commit a3befd3
Showing
8 changed files
with
211 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
pkg/front_end/parser_testcases/patterns/rest_withoutSubpattern_insideMap.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
void f(x) { | ||
switch (x) { | ||
case {...}: | ||
break; | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
pkg/front_end/parser_testcases/patterns/rest_withoutSubpattern_insideMap.dart.expect
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
beginCompilationUnit(void) | ||
beginMetadataStar(void) | ||
endMetadataStar(0) | ||
beginTopLevelMember(void) | ||
beginTopLevelMethod(, null, null) | ||
handleVoidKeyword(void) | ||
handleIdentifier(f, topLevelFunctionDeclaration) | ||
handleNoTypeVariables(() | ||
beginFormalParameters((, MemberKind.TopLevelMethod) | ||
beginMetadataStar(x) | ||
endMetadataStar(0) | ||
beginFormalParameter(x, MemberKind.TopLevelMethod, null, null, null) | ||
handleNoType(() | ||
handleIdentifier(x, formalParameterDeclaration) | ||
handleFormalParameterWithoutValue()) | ||
endFormalParameter(null, null, null, x, null, null, FormalParameterKind.requiredPositional, MemberKind.TopLevelMethod) | ||
endFormalParameters(1, (, ), MemberKind.TopLevelMethod) | ||
handleAsyncModifier(null, null) | ||
beginBlockFunctionBody({) | ||
beginSwitchStatement(switch) | ||
handleIdentifier(x, expression) | ||
handleNoTypeArguments()) | ||
handleNoArguments()) | ||
handleSend(x, )) | ||
handleParenthesizedCondition((, null, null) | ||
beginSwitchBlock({) | ||
beginCaseExpression(case) | ||
handleNoTypeArguments({) | ||
handleRestPattern(..., false) | ||
handleMapPattern(1, {, }) | ||
endCaseExpression(case, null, :) | ||
beginSwitchCase(0, 1, case) | ||
handleBreakStatement(false, break, ;) | ||
endSwitchCase(0, 1, null, null, 1, case, }) | ||
endSwitchBlock(1, {, }) | ||
endSwitchStatement(switch, }) | ||
endBlockFunctionBody(1, {, }) | ||
endTopLevelMethod(void, null, }) | ||
endTopLevelDeclaration() | ||
endCompilationUnit(1, ) |
93 changes: 93 additions & 0 deletions
93
...nt_end/parser_testcases/patterns/rest_withoutSubpattern_insideMap.dart.intertwined.expect
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
parseUnit(void) | ||
skipErrorTokens(void) | ||
listener: beginCompilationUnit(void) | ||
syntheticPreviousToken(void) | ||
parseTopLevelDeclarationImpl(, Instance of 'DirectiveContext') | ||
parseMetadataStar() | ||
listener: beginMetadataStar(void) | ||
listener: endMetadataStar(0) | ||
parseTopLevelMemberImpl() | ||
listener: beginTopLevelMember(void) | ||
parseTopLevelMethod(, null, null, , Instance of 'VoidType', null, f, false) | ||
listener: beginTopLevelMethod(, null, null) | ||
listener: handleVoidKeyword(void) | ||
ensureIdentifierPotentiallyRecovered(void, topLevelFunctionDeclaration, false) | ||
listener: handleIdentifier(f, topLevelFunctionDeclaration) | ||
parseMethodTypeVar(f) | ||
listener: handleNoTypeVariables(() | ||
parseGetterOrFormalParameters(f, f, false, MemberKind.TopLevelMethod) | ||
parseFormalParameters(f, MemberKind.TopLevelMethod) | ||
parseFormalParametersRest((, MemberKind.TopLevelMethod) | ||
listener: beginFormalParameters((, MemberKind.TopLevelMethod) | ||
parseFormalParameter((, FormalParameterKind.requiredPositional, MemberKind.TopLevelMethod) | ||
parseMetadataStar(() | ||
listener: beginMetadataStar(x) | ||
listener: endMetadataStar(0) | ||
listener: beginFormalParameter(x, MemberKind.TopLevelMethod, null, null, null) | ||
listener: handleNoType(() | ||
ensureIdentifier((, formalParameterDeclaration) | ||
listener: handleIdentifier(x, formalParameterDeclaration) | ||
listener: handleFormalParameterWithoutValue()) | ||
listener: endFormalParameter(null, null, null, x, null, null, FormalParameterKind.requiredPositional, MemberKind.TopLevelMethod) | ||
listener: endFormalParameters(1, (, ), MemberKind.TopLevelMethod) | ||
parseAsyncModifierOpt()) | ||
listener: handleAsyncModifier(null, null) | ||
inPlainSync() | ||
parseFunctionBody(), false, false) | ||
listener: beginBlockFunctionBody({) | ||
notEofOrValue(}, switch) | ||
parseStatement({) | ||
parseStatementX({) | ||
parseSwitchStatement({) | ||
listener: beginSwitchStatement(switch) | ||
ensureParenthesizedCondition(switch, allowCase: false) | ||
parseExpressionInParenthesisRest((, allowCase: false) | ||
parseExpression(() | ||
parsePrecedenceExpression((, 1, true) | ||
parseUnaryExpression((, true) | ||
parsePrimary((, expression) | ||
parseSendOrFunctionLiteral((, expression) | ||
parseSend((, expression) | ||
isNextIdentifier(() | ||
ensureIdentifier((, expression) | ||
listener: handleIdentifier(x, expression) | ||
listener: handleNoTypeArguments()) | ||
parseArgumentsOpt(x) | ||
listener: handleNoArguments()) | ||
listener: handleSend(x, )) | ||
ensureCloseParen(x, () | ||
listener: handleParenthesizedCondition((, null, null) | ||
parseSwitchBlock()) | ||
ensureBlock(), null, switch statement) | ||
listener: beginSwitchBlock({) | ||
notEofOrValue(}, case) | ||
peekPastLabels(case) | ||
listener: beginCaseExpression(case) | ||
parsePattern(case, precedence: 1, isRefutableContext: true) | ||
parsePrimaryPattern(case, isRefutableContext: true) | ||
listener: handleNoTypeArguments({) | ||
parseMapPatternSuffix(case, isRefutableContext: true) | ||
listener: handleRestPattern(..., false) | ||
listener: handleMapPattern(1, {, }) | ||
ensureColon(}) | ||
listener: endCaseExpression(case, null, :) | ||
peekPastLabels(break) | ||
parseStatementsInSwitchCase(:, break, case, 0, 1, null, null) | ||
listener: beginSwitchCase(0, 1, case) | ||
parseStatement(:) | ||
parseStatementX(:) | ||
parseBreakStatement(:) | ||
isBreakAllowed() | ||
ensureSemicolon(break) | ||
listener: handleBreakStatement(false, break, ;) | ||
peekPastLabels(}) | ||
listener: endSwitchCase(0, 1, null, null, 1, case, }) | ||
notEofOrValue(}, }) | ||
listener: endSwitchBlock(1, {, }) | ||
listener: endSwitchStatement(switch, }) | ||
notEofOrValue(}, }) | ||
listener: endBlockFunctionBody(1, {, }) | ||
listener: endTopLevelMethod(void, null, }) | ||
listener: endTopLevelDeclaration() | ||
reportAllErrorTokens(void) | ||
listener: endCompilationUnit(1, ) |
15 changes: 15 additions & 0 deletions
15
pkg/front_end/parser_testcases/patterns/rest_withoutSubpattern_insideMap.dart.parser.expect
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
void f(x) { | ||
switch (x) { | ||
case {...}: | ||
break; | ||
} | ||
} | ||
|
||
|
||
void[KeywordToken] f[StringToken]([BeginToken]x[StringToken])[SimpleToken] {[BeginToken] | ||
switch[KeywordToken] ([BeginToken]x[StringToken])[SimpleToken] {[BeginToken] | ||
case[KeywordToken] {[BeginToken]...[SimpleToken]}[SimpleToken]:[SimpleToken] | ||
break[KeywordToken];[SimpleToken] | ||
}[SimpleToken] | ||
}[SimpleToken] | ||
[SimpleToken] |
15 changes: 15 additions & 0 deletions
15
pkg/front_end/parser_testcases/patterns/rest_withoutSubpattern_insideMap.dart.scanner.expect
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
void f(x) { | ||
switch (x) { | ||
case {...}: | ||
break; | ||
} | ||
} | ||
|
||
|
||
void[KeywordToken] f[StringToken]([BeginToken]x[StringToken])[SimpleToken] {[BeginToken] | ||
switch[KeywordToken] ([BeginToken]x[StringToken])[SimpleToken] {[BeginToken] | ||
case[KeywordToken] {[BeginToken]...[SimpleToken]}[SimpleToken]:[SimpleToken] | ||
break[KeywordToken];[SimpleToken] | ||
}[SimpleToken] | ||
}[SimpleToken] | ||
[SimpleToken] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,7 @@ abbreviate | |
abc | ||
abcdef | ||
abs | ||
accepting | ||
accounting | ||
accounts | ||
accumulated | ||
|