1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
//! Destructuring binding patterns (ECMAScript §14.3.3).
//!
//! # The same shapes as an assignment pattern, and a different grammar
//!
//! `let [a] = b` and `[a] = b` look alike and are not related productions. A
//! [`super::Pattern`] is refined out of a literal by a cover grammar, and its targets are
//! `LeftHandSideExpression`s — anywhere a value can be put. A `BindingPattern` is parsed directly,
//! because a binding position expects one, and its targets are names being *created*:
//!
//! ```text
//! [a.b] = c legal — a.b is somewhere to put a value
//! let [a.b] = c not — there is no such thing as declaring `a.b`
//! ```
//!
//! So they are two types rather than one with a flag. Sharing them would mean a tree in which
//! `let [a.b]` is representable, and the parser being the only thing that knows it cannot happen.
//!
//! # A pattern always takes an initialiser
//!
//! `VariableDeclaration : BindingIdentifier Initializer_opt | BindingPattern Initializer` — the
//! `_opt` is on the first alternative only. `var a;` declares `a` as `undefined`; `var [a];` has
//! nothing to take apart, so it has no derivation at all. That holds for `var` and `let` as much
//! as for `const`, which is the one case where a *name* needs one too.
//!
//! # Where the rest elements differ, again
//!
//! `BindingRestElement : ... BindingIdentifier | ... BindingPattern`, and
//! `BindingRestProperty : ... BindingIdentifier`. The same asymmetry the assignment patterns
//! have, for the same reason: the remaining elements of an iterator can be taken apart, and the
//! remaining properties of an object are an object.
use ;
use crateSpan;
/// A name being declared, or a pattern of them (§14.3.3).
/// One declared name, and where it was written (§13.1).
/// An `ArrayBindingPattern` or an `ObjectBindingPattern` (§14.3.3).
/// `ArrayBindingPattern` (§14.3.3).
/// `ObjectBindingPattern` (§14.3.3).
/// One property of an object binding pattern (§14.3.3).
/// A binding and the value to use when what arrives is `undefined` (§14.3.3).