{ "scopeName": "source.swift", "fileTypes": [ "swift" ], "name": "Swift89", "firstLineMatch": "^#!\\s*/.*\\bswift", "patterns": [ { "include": "#comment" }, { "name": "keyword.others.swift", "match": "^\\s*(#if|#else|#endif|#elseif |@discardableResult|@testable|@inline)\\b" }, { "name": "keyword.declaration.swift", "match": "\\b(import(\\s(typealias|struct|class|enum|protocol|var|func))?|throws|rethrows)\\b" }, { "name": "storage.type.swift", "match": "\\b(let|var|class|struct|enum|extension|protocol|typealias|associatedtype)\\b" }, { "name": "storage.modifier.swift", "match": "\\b(final|internal|private|fileprivate|public|open|static|required|convenience|lazy)\\b" }, { "name": "keyword.controls.swift", "match": "\\b(try|catch|throw|repeat|break|case|continue|default|do|else|fallthrough|if|in|for|return|switch|where|while|guard|defer)\\b" }, { "name": "keyword.expressions-and-types.swift", "match": "\\b(#column|#file|#function|#line)\\b" }, { "name": "keyword.reserved.swift", "match": "\\b(infix|mutating|nonmutating|operator|override|postfix|precedence|prefix|unowned|unowned(safe)|unowned(unsafe)|weak)\\b(?!\\s*:)" }, { "name": "keyword.reserved.swift", "match": "\\->" }, { "name": "constant.language.swift", "match": "\\b(true|false|nil)\\b" }, { "name": "variable.language.swift", "match": "(\\b(self|Self|super)\\b|\\$[0-9]+)" }, { "name": "meta.type.swift", "begin": "\\b(precedencegroup)\\b", "beginCaptures": { "1": { "name": "storage.type.swift" } }, "end": "\\}", "patterns": [ { "name": "keyword.reserved.swift", "match": "\\b(associativity|higherThan|lowerThan|assignment)\\b" }, { "name": "support.type.swift", "match": "\\b((BitwiseShift|Multiplication|Addition|RangeFormation|Casting|NilCoalescing|Comparison|LogicalConjunction|LogicalDisjunction|Ternary|Assignment)Precedence)\\b" }, { "name": "keyword.reserved.swift", "match": "(?<=\\:)\\s*(left|right|none)\\b" }, { "include": "$self" } ] }, { "name": "meta.function.swift", "begin": "\\b(func)\\s+([^\\t\\n\\x20\\x28]+)\\s*\\(", "beginCaptures": { "1": { "name": "keyword.declaration.swift" }, "2": { "name": "entity.name.function.swift" } }, "end": "\\)", "patterns": [ { "name": "keyword.reserved.swift", "match": "(?<=\\:)\\s*(@escaping|@autoclosure|inout)\\s+" }, { "include": "$self" } ] }, { "name": "meta.function.swift", "begin": "\\b(init\\??|subscript|set|willSet|didSet)\\s*\\(", "beginCaptures": { "1": { "name": "entity.name.function.swift" } }, "end": "\\)", "patterns": [ { "name": "keyword.reserved.swift", "match": "(?<=\\:)\\s*(@escaping|@autoclosure|inout)\\s+" }, { "include": "$self" } ] }, { "name": "entity.name.function.swift", "match": "\\b(deinit|get|set|willSet|didSet)\\b" }, { "name": "keyword.operator.swift", "match": "(\\->|,|<|>|:|\\!|\\~|\\+|\\-|<<|>>|\\=|\\*|/|%|&|\\||\\^|\\.\\.<|\\.\\.\\.|\\bis\\b|\\bas[\\?\\!]\\b|\\bas\\b|\\?)" }, { "name": "support.type.swift", "match": "(?x) \\b(Character|U?Int|U?Int(8|16|32|64) |Swift |Float|Double|Float80|Bool |Unicode(\\.(Scalar|ASCII|UTF8|UTF16|UTF32|ParseResult|Encoding|Parser))? |BinaryInteger |FixedWidthInteger |Numeric |SignedNumeric |StringProtocol |SubString |UTF8 |UTF16 |UTF32 |Any |AnyBidirectionalCollection |AnyCollection |AnyHashable |AnyIndex |AnyIterator |AnyRandomAccessCollection |AnySequence |Array |ArraySlice |AutoreleasingUnsafeMutablePointer |BidirectionalSlice |CVaListPointer |ClosedRange |ClosedRangeIndex |ClosedRangeIterator |CollectionOfOne |ContiguousArray |CountableClosedRange |CountableRange |DefaultBidirectionalIndices |DefaultIndices |DefaultRandomAccessIndices |Dictionary |DictionaryIterator |DictionaryLiteral |EmptyCollection |EmptyIterator |EnumeratedIterator |EnumeratedSequence |Flatten(BidirectionalCollectionIndex|BidirectionalCollection|CollectionIndex|Collection|Iterator|Sequence) |IndexingIterator |IteratorOverOne |IteratorSequence |JoinedIterator |JoinedSequence |LazyBidirectionalCollection |Lazy(Collection |(DropWhile|Filter|PrefixWhile)(BidirectionalCollection|Collection|Index|Iterator|Sequence) |MapBidirectionalCollection |MapCollection |MapIterator |MapRandomAccessCollection |MapSequence |RandomAccessCollection |Sequence) |ManagedBufferPointer |Mirror |Mutable(Bidirectional|RandomAccess|RangeReplaceableBidirectional|RangeReplaceable)Slice |MutableSlice |ObjectIdentifier |OpaquePointer |RandomAccessSlice |Range |RangeReplaceable(BidirectionalSlice|RandomAccessSlice|Slice) |Repeated |ReversedCollection |ReversedIndex |ReversedRandomAccessCollection |ReversedRandomAccessIndex |Set |SetIterator |Slice |StaticString |Stride(ThroughIterator|Through|ToIterator|To) |String |UnfoldSequence |Unmanaged |Unsafe(Mutable)?(Raw)?BufferPointer(Iterator)? |Unsafe(Mutable)?(Raw)?Pointer |Zip2Iterator |Zip2Sequence |ManagedBuffer |CommandLine |FloatingPointClassification |FloatingPointRoundingRule |FloatingPointSign |ImplicitlyUnwrappedOptional |MemoryLayout |Never |Optional |UnicodeDecodingResult |AbsoluteValuable |AnyObject |BidirectionalCollection |BinaryFloatingPoint |BitwiseOperations |CVarArg |Collection |Comparable |CustomDebugStringConvertible |CustomLeafReflectable |CustomReflectable |Equatable |Error |ExpressibleBy(Array|Boolean|Dictionary|ExtendedGraphemeCluster|Float|Integer|Nil|String|UnicodeScalar)Literal |ExpressibleByStringInterpolation |FloatingPoint |Hashable |Integer |IntegerArithmetic |IteratorProtocol |LazyCollectionProtocol |LazySequenceProtocol |LosslessStringConvertible |MirrorPath |MutableCollection |OptionSet |RandomAccessCollection |RangeReplaceableCollection |RawRepresentable |Sequence |SetAlgebra |SignedInteger |SignedNumber |Strideable |TextOutputStream |TextOutputStreamable |UnicodeCodec |UnsignedInteger |AnyClass |BooleanLiteralType |C(Bool|Char(16|32)?|Double|Float|Int|LongLong|Long|Short|SignedChar|Unsigned(Int|LongLong|Long|Short)|WideChar) |DictionaryIndex |ExtendedGraphemeClusterType |Float(32|64) |FloatLiteralType |IntMax |IntegerLiteralType |SetIndex |UIntMax |UnfoldFirstSequence |UnicodeScalar |UnicodeScalarType |Void)\\b" }, { "name": "support.function.swift", "match": "(?x) \\b(?\\\\\\s*\\n)" } ] } ] } ] }, "escaped-char": { "patterns": [ { "name": "constant.character.escape.swift", "match": "\\\\[0\\\\tnr\"']" }, { "name": "constant.character.escape.swift", "match": "\\\\u\\{\\h+\\}" }, { "name": "invalid.illegal.constant.character.escape.swift", "match": "\\\\[^uxU]" } ] }, "identifier": { "match": "(?x) (? \\g \\g? | ` \\g \\g? ` ){0} (? [ a-z A-Z ] | [ \\u00A8 \\u00AA \\u00AD \\u00AF \\u00B2-\\u00B5 \\u00B7-\\u00BA ] | [ \\u00BC-\\u00BE \\u00C0-\\u00D6 \\u00D8-\\u00F6 \\u00F8-\\u00FF ] | [ \\u0100-\\u02FF \\u0370-\\u167F \\u1681-\\u180D \\u180F-\\u1DBF ] | [ \\u1E00-\\u1FFF ] | [ \\u200B-\\u200D \\u202A-\\u202E \\u203F-\\u2040 \\u2054 \\u2060-\\u206F ] | [ \\u2070-\\u20CF \\u2100-\\u218F \\u2460-\\u24FF \\u2776-\\u2793 ] | [ \\u2C00-\\u2DFF \\u2E80-\\u2FFF ] | [ \\u3004-\\u3007 \\u3021-\\u302F \\u3031-\\u303F \\u3040-\\uD7FF ] | [ \\uF900-\\uFD3D \\uFD40-\\uFDCF \\uFDF0-\\uFE1F \\uFE30-\\uFE44 ] | [ \\uFE47-\\uFFFD ] | [ \\u10000-\\u1FFFD \\u20000-\\u2FFFD \\u30000-\\u3FFFD \\u40000-\\u4FFFD ] | [ \\u50000-\\u5FFFD \\u60000-\\u6FFFD \\u70000-\\u7FFFD \\u80000-\\u8FFFD ] | [ \\u90000-\\u9FFFD \\uA0000-\\uAFFFD \\uB0000-\\uBFFFD \\uC0000-\\uCFFFD ] | [ \\uD0000-\\uDFFFD \\uE0000-\\uEFFFD ] ){0} (? \\d | [ \\u0300-\\u036F \\u1DC0-\\u1DFF \\u20D0-\\u20FF \\uFE20-\\uFE2F ] | \\g ){0} (? \\g \\g? ){0} \\g | \\g", "captures": { "5": { "name": "variable.other.positional.swift" } } }, "literal": { "patterns": [ { "include": "#literal-number" }, { "include": "#literal-string" } ] }, "literal-number": { "name": "constant.numeric.swift", "match": "(?x) (?### INTEGER ###) (? \\g | \\g | \\g | \\g ){0} (?### BINARY ###) (? \\b 0b \\g \\g? \\b ){0} (? [0-1] ){0} (? \\g | _ ){0} (? \\g \\g? ){0} (?### OCTAL ###) (? \\b 0o \\g \\g? \\b ){0} (? [0-7] ){0} (? \\g | _ ){0} (? \\g \\g? ){0} (?### DECIMAL ###) (? \\b \\g \\g? \\b ){0} (? \\d ){0} (? \\g | _ ){0} (? \\g \\g? ){0} (?### HEXADECIMAL ###) (? \\b 0x \\g \\g? \\b ){0} (? \\h ){0} (? \\g | _ ){0} (? \\g \\g? ){0} (?### FLOATING POINT ###) (? \\b \\g \\g? \\g? \\b | \\b \\g \\g? \\g \\b ){0} (? \\. \\g ){0} (? \\g \\g? \\g ){0} (? \\. \\g? ){0} (? \\g \\g? \\g ){0} (? [eE] ){0} (? [pP] ){0} (? [+-] ){0} (?!0[box]) \\g | \\g" }, "literal-string": { "name": "string.quoted.double.swift", "begin": "\"", "end": "\"", "beginCaptures": { "0": { "name": "punctuation.definition.string.begin.swift" } }, "endCaptures": { "0": { "name": "punctuation.definition.string.end.swift" } }, "patterns": [ { "include": "#quoted-text" } ] }, "quoted-text": { "patterns": [ { "name": "meta.embedded.line.swift", "contentName": "source.swift", "begin": "\\\\\\(", "end": "\\)", "beginCaptures": { "0": { "name": "punctuation.section.embedded.begin.swift" } }, "endCaptures": { "0": { "name": "punctuation.section.embedded.end.swift" } }, "patterns": [ { "include": "$self" } ] }, { "include": "#escaped-char" } ] }, "whitespace": { "match": "(?x) [ \\u0020 (?# space) \\u000A (?# line-feed) \\u000D (?# carriage-return) \\u0009 (?# horizontal-tab) \\u000B (?# vertical-tab) \\u000C (?# form-feed) \\u0000 (?# null) ]" } } }