Skip to content

Commit ccc1dd5

Browse files
committed
Unified: Add tuple_pattern
1 parent a966dff commit ccc1dd5

3 files changed

Lines changed: 9 additions & 10 deletions

File tree

unified/extractor/ast_types.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ supertypes:
2222
pattern:
2323
- var_pattern
2424
- apply_pattern
25+
- tuple_pattern
2526
- ignore_pattern
2627
- unsupported_node
2728
named:
@@ -109,6 +110,10 @@ named:
109110
constructor: expr
110111
argument*: pattern
111112

113+
# A tuple pattern such as `(a, b)` in `let (a, b) = pair`.
114+
tuple_pattern:
115+
element*: pattern
116+
112117
# An simple unqualified identifier token
113118
identifier:
114119

unified/extractor/src/languages/swift/swift.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -244,14 +244,11 @@ fn translation_rules() -> Vec<yeast::Rule> {
244244
),
245245
// Tuple destructuring pattern, e.g. `let (a, b) = pair`. The parser
246246
// emits a `pattern` node whose unnamed children are themselves
247-
// `pattern` nodes. We synthesize a `tuple` constructor since the
248-
// syntax has no name.
247+
// `pattern` nodes.
249248
rule!(
250249
(pattern (pattern)+ @parts)
251250
=>
252-
(apply_pattern
253-
constructor: (name_expr identifier: (identifier "tuple"))
254-
argument: {..parts})
251+
(tuple_pattern element: {..parts})
255252
),
256253
// ---- Variable declarations ----
257254
// Handles single (`let x = e`), multiple (`let x = 1, y = 2`),

unified/extractor/tests/corpus/swift/variables.txt

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -151,15 +151,12 @@ top_level
151151
name_expr
152152
identifier: identifier "pair"
153153
pattern:
154-
apply_pattern
155-
argument:
154+
tuple_pattern
155+
element:
156156
var_pattern
157157
identifier: identifier "a"
158158
var_pattern
159159
identifier: identifier "b"
160-
constructor:
161-
name_expr
162-
identifier: identifier "tuple"
163160

164161
===
165162
Multiple bindings on one line

0 commit comments

Comments
 (0)