Explorar el Código

Merge pull request #2855 from philipturner/main

Update Swift language specification to version 5.5
Alexandru Dima hace 3 años
padre
commit
bfb6a42e3d
Se han modificado 2 ficheros con 87 adiciones y 25 borrados
  1. 2 2
      src/basic-languages/swift/swift.test.ts
  2. 85 23
      src/basic-languages/swift/swift.ts

+ 2 - 2
src/basic-languages/swift/swift.test.ts

@@ -9,12 +9,12 @@ testTokenization('swift', [
 	// Attributes
 	[
 		{
-			line: '@noescape',
+			line: '@escaping',
 			tokens: [
 				{
 					startIndex: 0,
 					type: 'keyword.control.swift'
-				} /* '@noescape' */
+				} /* '@escaping' */
 			]
 		}
 	],

+ 85 - 23
src/basic-languages/swift/swift.ts

@@ -38,33 +38,84 @@ export const language = <languages.IMonarchLanguage>{
 
 	// TODO(owensd): Support the full range of unicode valid identifiers.
 	identifier: /[a-zA-Z_][\w$]*/,
-	// TODO(owensd): Support the @availability macro properly.
+
 	attributes: [
-		'@autoclosure',
-		'@noescape',
-		'@noreturn',
+		'@GKInspectable',
+		'@IBAction',
+		'@IBDesignable',
+		'@IBInspectable',
+		'@IBOutlet',
+		'@IBSegueAction',
 		'@NSApplicationMain',
 		'@NSCopying',
 		'@NSManaged',
-		'@objc',
+		'@Sendable',
 		'@UIApplicationMain',
+
+		'@autoclosure',
+		'@actorIndependent',
+		'@asyncHandler',
+		'@available',
+		'@convention',
+		'@derivative', // Swift for TensorFlow
+		'@differentiable', // Swift for TensorFlow
+		'@discardableResult',
+		'@dynamicCallable',
+		'@dynamicMemberLookup',
+		'@escaping',
+		'@frozen',
+		'@globalActor',
+		'@inlinable',
+		'@inline',
+		'@main',
+		'@nonobjc',
 		'@noreturn',
-		'@availability',
-		'@IBAction',
-		'@IBDesignable',
-		'@IBInspectable',
-		'@IBOutlet'
+		'@objc',
+		'@objcMembers',
+		'@propertyWrapper',
+		'@requires_stored_property_inits',
+		'@resultBuilder',
+		'@testable',
+		'@unchecked',
+		'@unknown',
+		'@usableFromInline',
+		'@warn_unqualified_access'
 	],
-	accessmodifiers: ['public', 'private', 'fileprivate', 'internal'],
+	accessmodifiers: ['open', 'public', 'internal', 'fileprivate', 'private'],
 	keywords: [
-		'__COLUMN__',
-		'__FILE__',
-		'__FUNCTION__',
-		'__LINE__',
+		'#available',
+		'#colorLiteral',
+		'#column',
+		'#dsohandle',
+		'#else',
+		'#elseif',
+		'#endif',
+		'#error',
+		'#file',
+		'#fileID',
+		'#fileLiteral',
+		'#filePath',
+		'#function',
+		'#if',
+		'#imageLiteral',
+		'#keyPath',
+		'#line',
+		'#selector',
+		'#sourceLocation',
+		'#warning',
+
+		'Any',
+		'Protocol',
+		'Self',
+		'Type',
+
+		'actor',
 		'as',
-		'as!',
-		'as?',
+		'assignment',
+		'associatedtype',
 		'associativity',
+		'async',
+		'await',
 		'break',
 		'case',
 		'catch',
@@ -72,6 +123,7 @@ export const language = <languages.IMonarchLanguage>{
 		'continue',
 		'convenience',
 		'default',
+		'defer',
 		'deinit',
 		'didSet',
 		'do',
@@ -81,44 +133,53 @@ export const language = <languages.IMonarchLanguage>{
 		'enum',
 		'extension',
 		'fallthrough',
+		'false',
 		'fileprivate',
 		'final',
 		'for',
 		'func',
 		'get',
 		'guard',
+		'higherThan',
 		'if',
 		'import',
 		'in',
+		'indirect',
 		'infix',
 		'init',
 		'inout',
 		'internal',
 		'is',
+		'isolated',
 		'lazy',
 		'left',
 		'let',
+		'lowerThan',
 		'mutating',
 		'nil',
 		'none',
+		'nonisolated',
 		'nonmutating',
+		'open',
 		'operator',
 		'optional',
 		'override',
 		'postfix',
 		'precedence',
+		'precedencegroup',
 		'prefix',
 		'private',
 		'protocol',
-		'Protocol',
 		'public',
 		'repeat',
 		'required',
+		'rethrows',
 		'return',
 		'right',
+		'safe',
 		'self',
-		'Self',
 		'set',
+		'some',
 		'static',
 		'struct',
 		'subscript',
@@ -126,18 +187,19 @@ export const language = <languages.IMonarchLanguage>{
 		'switch',
 		'throw',
 		'throws',
+		'true',
 		'try',
-		'try!',
-		'Type',
 		'typealias',
 		'unowned',
+		'unsafe',
 		'var',
 		'weak',
 		'where',
 		'while',
 		'willSet',
-		'FALSE',
-		'TRUE'
+
+		'__consuming',
+		'__owned'
 	],
 
 	symbols: /[=(){}\[\].,:;@#\_&\-<>`?!+*\\\/]/,