Skip to content

Commit f92206f

Browse files
eernstgCommit Queue
authored and
Commit Queue
committed
Change pattern rules (rename extractor->object, add metadata)
This CL changes the spec parser grammar, Dart.g, such that its pattern related rules correspond to the recent updates in the patterns feature specification. Change-Id: I8d07cdb4c7ce22e0625da5bc8224ca2cf57af095 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/268920 Reviewed-by: William Hesse <[email protected]> Auto-Submit: Erik Ernst <[email protected]> Commit-Queue: Erik Ernst <[email protected]>
1 parent 1d64cba commit f92206f

File tree

1 file changed

+8
-14
lines changed

1 file changed

+8
-14
lines changed

tools/spec_parser/Dart.g

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
// CHANGES:
66
//
7+
// v0.22 Change pattern rules, following updated feature specification.
8+
//
79
// v0.21 Add support for patterns.
810
//
911
// v0.20 Adjust record syntax such that () is allowed (denoting the empty
@@ -1043,7 +1045,7 @@ primaryPattern
10431045
| listPattern
10441046
| mapPattern
10451047
| recordPattern
1046-
| extractorPattern
1048+
| objectPattern
10471049
;
10481050
10491051
castPattern
@@ -1107,15 +1109,8 @@ patternField
11071109
: (identifier? ':')? pattern
11081110
;
11091111
1110-
extractorPattern
1111-
: extractorName typeArguments? '(' patternFields? ')'
1112-
;
1113-
1114-
// TODO: Could this be a single case containing `typeName`?
1115-
// I don't think we need `C.new` or `N1.N2.N3` or `N1.N2.new`.
1116-
extractorName
1117-
: typeIdentifier
1118-
| qualifiedName
1112+
objectPattern
1113+
: typeName typeArguments? '(' patternFields? ')'
11191114
;
11201115
11211116
patternVariableDeclaration
@@ -1127,7 +1122,7 @@ outerPattern
11271122
| listPattern
11281123
| mapPattern
11291124
| recordPattern
1130-
| extractorPattern
1125+
| objectPattern
11311126
;
11321127
11331128
patternAssignment
@@ -1172,10 +1167,9 @@ expressionStatement
11721167
: expression? ';'
11731168
;
11741169
1175-
// TODO: make it `metadata patternVariableDeclaration ';'`?
11761170
localVariableDeclaration
11771171
: metadata initializedVariableDeclaration ';'
1178-
| patternVariableDeclaration ';'
1172+
| metadata patternVariableDeclaration ';'
11791173
;
11801174
11811175
initializedVariableDeclaration
@@ -1199,7 +1193,7 @@ forLoopParts
11991193
: metadata declaredIdentifier IN expression
12001194
| metadata identifier IN expression
12011195
| forInitializerStatement expression? ';' expressionList?
1202-
| ('final' | 'var') outerPattern 'in' expression
1196+
| metadata (FINAL | VAR) outerPattern IN expression
12031197
;
12041198
12051199
// The localVariableDeclaration cannot be CONST, but that can

0 commit comments

Comments
 (0)