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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
//! The pieces the literal forms are made of (ECMAScript §13.2), and the regular-expression node.
//!
//! Split from [`super::expression`] because these are the *parts* rather than the expressions:
//! nothing here is an `ExprKind`, and each is held by exactly one variant of it. Keeping them
//! apart leaves that enum readable as the catalogue it is.
use Expr;
use crateSpan;
/// One element of an array literal (§13.2.4).
///
/// A hole is an element and not an absence: `[, 1]` has two of them, and `[1, ]` has one. The
/// difference is whether a comma had anything before it in its slot, which is the whole content
/// of `Elision` and the one thing about array literals that is easy to get wrong.
/// One entry of an object literal (§13.2.5).
/// A `TemplateLiteral` (§13.2.8) — its literal parts, and the expressions between them.
///
/// `quasis` is always one longer than `expressions`: a template begins and ends with a literal
/// part, even when that part is empty. `` `${a}` `` has two empty ones.
/// One literal component of a template (§12.9.6).
/// Which kind of `MethodDefinition` (§15.4).
/// What names a property (§13.2.5).
///
/// The source forms are kept apart rather than reduced to one string, because reducing them needs
/// `PropName`, and `PropName` of a `NumericLiteral` is `ToString` of its value — an abstract
/// operation this engine does not have yet. Inventing an approximation would be a bug that only
/// ever showed up in a property name.
/// A `BigIntLiteral` (§12.9.3), as the digits it is made of.
///
/// Not as a value, because the value is a BigInt — a mathematical integer of no fixed width — and
/// this engine has no such type until M7. Approximating one with an `f64` would be a bug that
/// showed up only in the numbers BigInt exists for: `9007199254740993n` is the first integer an
/// `f64` cannot hold, and webpack's test suite writes it down precisely because of that.
///
/// So the parser does the part it can do without arithmetic — strip the separators, the prefix
/// and the suffix, and record which radix the prefix asked for — and leaves `StringToBigInt`
/// (§7.1.14) to whoever owns the value representation. Nothing has to be lexed twice.
/// The two halves of a regular expression literal, as written.
///
/// Neither is parsed here: §12.9.5 says both "are subsequently parsed again using the more
/// stringent ECMAScript Regular Expression grammar", which is the RegExp engine's work at M4. So
/// an unparsable pattern is a perfectly good node, and stops being one later.