Skip to content

Commit

Permalink
Merge pull request #2855 from philipturner/main
Browse files Browse the repository at this point in the history
Update Swift language specification to version 5.5
  • Loading branch information
alexdima committed Jan 14, 2022
2 parents c9e1c99 + 29454a6 commit bfb6a42
Show file tree
Hide file tree
Showing 2 changed files with 87 additions and 25 deletions.
4 changes: 2 additions & 2 deletions src/basic-languages/swift/swift.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ testTokenization('swift', [
// Attributes
[
{
line: '@noescape',
line: '@escaping',
tokens: [
{
startIndex: 0,
type: 'keyword.control.swift'
} /* '@noescape' */
} /* '@escaping' */
]
}
],
Expand Down
108 changes: 85 additions & 23 deletions src/basic-languages/swift/swift.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,40 +38,92 @@ 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',
'class',
'continue',
'convenience',
'default',
'defer',
'deinit',
'didSet',
'do',
Expand All @@ -81,63 +133,73 @@ 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',
'super',
'switch',
'throw',
'throws',
'true',
'try',
'try!',
'Type',
'typealias',
'unowned',
'unsafe',
'var',
'weak',
'where',
'while',
'willSet',
'FALSE',
'TRUE'

'__consuming',
'__owned'
],

symbols: /[=(){}\[\].,:;@#\_&\-<>`?!+*\\\/]/,
Expand Down

0 comments on commit bfb6a42

Please sign in to comment.