@@ -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,127 @@ 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,
234
+ // Accessors
235
+ . get, . set, . didSet, . willSet, . unsafeAddress, . addressWithOwner, . addressWithNativeOwner, . unsafeMutableAddress,
236
+ . mutableAddressWithOwner, . mutableAddressWithNativeOwner, . _read, . _modify,
230
237
// Misc
231
238
. import:
232
239
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
240
+
241
+ case // `TypeAttribute`
242
+ . _noMetadata,
243
+ . _opaqueReturnTypeOf,
244
+ . autoclosure,
245
+ . convention,
246
+ . differentiable,
247
+ . escaping,
248
+ . noDerivative,
249
+ . noescape,
250
+ . Sendable,
251
+ . unchecked:
252
+ self = . exprKeyword
253
+
254
+ case // `DeclarationAttributeWithSpecialSyntax`
255
+ . _alignment,
256
+ . _backDeploy,
257
+ . _cdecl,
258
+ . _documentation,
259
+ . _dynamicReplacement,
260
+ . _effects,
261
+ . _expose,
262
+ . _implements,
263
+ . _nonSendable,
264
+ . _objcImplementation,
265
+ . _objcRuntimeName,
266
+ . _optimize,
267
+ . _originallyDefinedIn,
268
+ . _private,
269
+ . _projectedValueProperty,
270
+ . _semantics,
271
+ . _specialize,
272
+ . _spi,
273
+ . _spi_available,
274
+ . _swift_native_objc_runtime_base,
275
+ . _typeEraser,
276
+ . _unavailableFromAsync,
277
+ . attached,
278
+ . available,
279
+ . backDeployed,
280
+ . derivative,
281
+ . exclusivity,
282
+ . inline,
283
+ . objc,
284
+ . transpose:
285
+ self = . exprKeyword
286
+
287
+ case // Treat all other keywords as expression keywords in the absence of any better information.
288
+ . __owned,
289
+ . __shared,
290
+ . _Class,
291
+ . _compilerInitialized,
292
+ . _const,
293
+ . _forward,
294
+ . _linear,
295
+ . _move,
296
+ . _NativeClass,
297
+ . _NativeRefCountedObject,
298
+ . _PackageDescription,
299
+ . _RefCountedObject,
300
+ . _Trivial,
301
+ . _TrivialAtMost,
302
+ . _underlyingVersion,
303
+ . _UnknownLayout,
304
+ . _version,
305
+ . accesses,
306
+ . any,
307
+ . assignment,
308
+ . associativity,
309
+ . availability,
310
+ . before,
311
+ . block,
312
+ . canImport,
313
+ . compiler,
314
+ . cType,
315
+ . deprecated,
316
+ . exported,
317
+ . file,
318
+ . discard,
319
+ . forward,
320
+ . higherThan,
321
+ . initializes,
322
+ . introduced,
323
+ . kind,
324
+ . left,
325
+ . line,
326
+ . linear,
327
+ . lowerThan,
328
+ . message,
329
+ . metadata,
330
+ . module,
331
+ . noasync,
332
+ . none,
333
+ . obsoleted,
334
+ . of,
335
+ . Protocol,
336
+ . renamed,
337
+ . reverse,
338
+ . right,
339
+ . safe,
340
+ . sourceFile,
341
+ . spi,
342
+ . spiModule,
343
+ . swift,
344
+ . target,
345
+ . Type,
346
+ . unavailable,
347
+ . unowned,
348
+ . visibility,
349
+ . weak,
350
+ . witness_method,
351
+ . wrt,
352
+ . unsafe:
236
353
self = . exprKeyword
237
354
}
238
355
}
0 commit comments