@@ -192,29 +192,33 @@ enum TokenPrecedence: Comparable {
192
192
case // Literals
193
193
. Self, . false , . nil , . `self`, . super, . true :
194
194
self = . identifierLike
195
+
195
196
// MARK: Expr keyword
196
197
case // Keywords
197
- . as, . is, . try ,
198
+ . as, . is, . some, . try ,
199
+ . await , . each, . copy,
198
200
// We don't know much about which contextual keyword it is, be conservative an allow considering it as unexpected.
199
201
// Keywords in function types (we should be allowed to skip them inside parenthesis)
200
- . rethrows, . throws,
202
+ . rethrows, . throws, . reasync , . async ,
201
203
// Consider 'any' a prefix operator to a type and a type is expression-like.
202
204
. Any,
203
205
// 'where' can only occur in the signature of declarations. Consider the signature expression-like.
204
206
. where,
205
207
// 'in' occurs in closure input/output definitions and for loops. Consider both constructs expression-like.
206
208
. in:
207
209
self = . exprKeyword
210
+
208
211
case // Control-flow constructs
209
212
. defer, . do, . for, . guard, . if, . repeat , . switch, . while,
210
213
// Secondary parts of control-flow constructs
211
214
. case, . catch, . default, . else,
212
215
// Return-like statements
213
216
. break, . continue, . fallthrough, . return, . throw, . then, . yield:
214
217
self = . stmtKeyword
218
+
215
219
// MARK: Decl keywords
216
220
case // Types
217
- . associatedtype, . class, . enum, . extension, . protocol, . struct, . typealias,
221
+ . associatedtype, . class, . enum, . extension, . protocol, . struct, . typealias, . actor , . macro ,
218
222
// Access modifiers
219
223
. fileprivate, . internal, . private, . public, . static,
220
224
// Functions
@@ -225,14 +229,130 @@ enum TokenPrecedence: Comparable {
225
229
. operator, . precedencegroup,
226
230
// Declaration Modifiers
227
231
. __consuming, . final, . required, . optional, . lazy, . dynamic, . infix, . postfix, . prefix, . mutating, . nonmutating, . convenience, . override, . package , . open,
228
- . __setter_access, . indirect, . nonisolated, . distributed, . _local,
229
- . inout, . _mutating, . _borrowing, . _consuming,
232
+ . __setter_access, . indirect, . isolated , . nonisolated, . distributed, . _local,
233
+ . inout, . _mutating, . _borrow , . _borrowing, . borrowing , . _consuming, . consuming , . consume ,
230
234
// Misc
231
235
. import:
232
236
self = . declKeyword
233
- default :
234
- // Treat all keywords that weren't handled above as expression keywords as a fallback option.
235
- // FIXME: We should assign a token precedence to all keywords
237
+
238
+ case // Treat all other keywords as expression keywords in the absence of any better information.
239
+ . __owned,
240
+ . __shared,
241
+ . _alignment,
242
+ . _backDeploy,
243
+ . _cdecl,
244
+ . _Class,
245
+ . _compilerInitialized,
246
+ . _const,
247
+ . _documentation,
248
+ . _dynamicReplacement,
249
+ . _effects,
250
+ . _expose,
251
+ . _forward,
252
+ . _implements,
253
+ . _linear,
254
+ . _modify,
255
+ . _move,
256
+ . _NativeClass,
257
+ . _NativeRefCountedObject,
258
+ . _noMetadata,
259
+ . _nonSendable,
260
+ . _objcImplementation,
261
+ . _objcRuntimeName,
262
+ . _opaqueReturnTypeOf,
263
+ . _optimize,
264
+ . _originallyDefinedIn,
265
+ . _PackageDescription,
266
+ . _private,
267
+ . _projectedValueProperty,
268
+ . _read,
269
+ . _RefCountedObject,
270
+ . _semantics,
271
+ . _specialize,
272
+ . _spi,
273
+ . _spi_available,
274
+ . _swift_native_objc_runtime_base,
275
+ . _Trivial,
276
+ . _TrivialAtMost,
277
+ . _typeEraser,
278
+ . _unavailableFromAsync,
279
+ . _underlyingVersion,
280
+ . _UnknownLayout,
281
+ . _version,
282
+ . accesses,
283
+ . addressWithNativeOwner,
284
+ . addressWithOwner,
285
+ . any,
286
+ . assignment,
287
+ . associativity,
288
+ . attached,
289
+ . autoclosure,
290
+ . availability,
291
+ . available,
292
+ . backDeployed,
293
+ . before,
294
+ . block,
295
+ . canImport,
296
+ . compiler,
297
+ . convention,
298
+ . cType,
299
+ . deprecated,
300
+ . derivative,
301
+ . didSet,
302
+ . differentiable,
303
+ . escaping,
304
+ . exclusivity,
305
+ . exported,
306
+ . file,
307
+ . discard,
308
+ . forward,
309
+ . get,
310
+ . higherThan,
311
+ . initializes,
312
+ . inline,
313
+ . introduced,
314
+ . kind,
315
+ . left,
316
+ . line,
317
+ . linear,
318
+ . lowerThan,
319
+ . message,
320
+ . metadata,
321
+ . module,
322
+ . mutableAddressWithNativeOwner,
323
+ . mutableAddressWithOwner,
324
+ . noasync,
325
+ . noDerivative,
326
+ . noescape,
327
+ . none,
328
+ . objc,
329
+ . obsoleted,
330
+ . of,
331
+ . Protocol,
332
+ . renamed,
333
+ . reverse,
334
+ . right,
335
+ . safe,
336
+ . Sendable,
337
+ . set,
338
+ . sourceFile,
339
+ . spi,
340
+ . spiModule,
341
+ . swift,
342
+ . target,
343
+ . transpose,
344
+ . Type,
345
+ . unavailable,
346
+ . unchecked,
347
+ . unowned,
348
+ . unsafeAddress,
349
+ . unsafeMutableAddress,
350
+ . visibility,
351
+ . weak,
352
+ . willSet,
353
+ . witness_method,
354
+ . wrt,
355
+ . unsafe:
236
356
self = . exprKeyword
237
357
}
238
358
}
0 commit comments