...
1<lexer>
2 <config>
3 <name>Swift</name>
4 <alias>swift</alias>
5 <filename>*.swift</filename>
6 <mime_type>text/x-swift</mime_type>
7 </config>
8 <rules>
9 <state name="comment">
10 <rule pattern=":param: [a-zA-Z_]\w*|:returns?:|(FIXME|MARK|TODO):">
11 <token type="CommentSpecial"/>
12 </rule>
13 </state>
14 <state name="preproc">
15 <rule pattern="\n">
16 <token type="Text"/>
17 <pop depth="1"/>
18 </rule>
19 <rule>
20 <include state="keywords"/>
21 </rule>
22 <rule pattern="[A-Za-z]\w*">
23 <token type="CommentPreproc"/>
24 </rule>
25 <rule>
26 <include state="root"/>
27 </rule>
28 </state>
29 <state name="comment-single">
30 <rule pattern="\n">
31 <token type="Text"/>
32 <pop depth="1"/>
33 </rule>
34 <rule>
35 <include state="comment"/>
36 </rule>
37 <rule pattern="[^\n]">
38 <token type="CommentSingle"/>
39 </rule>
40 </state>
41 <state name="module">
42 <rule pattern="\n">
43 <token type="Text"/>
44 <pop depth="1"/>
45 </rule>
46 <rule pattern="[a-zA-Z_]\w*">
47 <token type="NameClass"/>
48 </rule>
49 <rule>
50 <include state="root"/>
51 </rule>
52 </state>
53 <state name="string">
54 <rule pattern="\\\(">
55 <token type="LiteralStringInterpol"/>
56 <push state="string-intp"/>
57 </rule>
58 <rule pattern=""">
59 <token type="LiteralString"/>
60 <pop depth="1"/>
61 </rule>
62 <rule pattern="\\['"\\nrt]|\\x[0-9a-fA-F]{2}|\\[0-7]{1,3}|\\u[0-9a-fA-F]{4}|\\U[0-9a-fA-F]{8}">
63 <token type="LiteralStringEscape"/>
64 </rule>
65 <rule pattern="[^\\"]+">
66 <token type="LiteralString"/>
67 </rule>
68 <rule pattern="\\">
69 <token type="LiteralString"/>
70 </rule>
71 </state>
72 <state name="string-intp">
73 <rule pattern="\(">
74 <token type="LiteralStringInterpol"/>
75 <push/>
76 </rule>
77 <rule pattern="\)">
78 <token type="LiteralStringInterpol"/>
79 <pop depth="1"/>
80 </rule>
81 <rule>
82 <include state="root"/>
83 </rule>
84 </state>
85 <state name="root">
86 <rule pattern="\n">
87 <token type="Text"/>
88 </rule>
89 <rule pattern="\s+">
90 <token type="Text"/>
91 </rule>
92 <rule pattern="//">
93 <token type="CommentSingle"/>
94 <push state="comment-single"/>
95 </rule>
96 <rule pattern="/\*">
97 <token type="CommentMultiline"/>
98 <push state="comment-multi"/>
99 </rule>
100 <rule pattern="#(if|elseif|else|endif|available)\b">
101 <token type="CommentPreproc"/>
102 <push state="preproc"/>
103 </rule>
104 <rule>
105 <include state="keywords"/>
106 </rule>
107 <rule pattern="(ExtendedGraphemeClusterLiteralConvertible|_SwiftNSDictionaryRequiredOverridesType|_SwiftNSStringRequiredOverridesType|_SwiftNSArrayRequiredOverridesType|AutoreleasingUnsafeMutablePointer|UnicodeScalarLiteralConvertible|RangeReplaceableCollectionType|StringInterpolationConvertible|DictionaryLiteralConvertible|UnsafeBufferPointerGenerator|_SwiftNSFastEnumerationType|LazyBidirectionalCollection|ExtendedGraphemeClusterType|FloatingPointClassification|ImplicitlyUnwrappedOptional|UnsafeMutableBufferPointer|LazyRandomAccessCollection|FilterCollectionViewIndex|_ExtensibleCollectionType|IntegerLiteralConvertible|ReverseBidirectionalIndex|BooleanLiteralConvertible|StringLiteralConvertible|BidirectionalReverseView|ReverseRandomAccessIndex|ExtensibleCollectionType|FloatLiteralConvertible|RandomAccessReverseView|_BidirectionalIndexType|ArrayLiteralConvertible|_RandomAccessIndexType|_IntegerArithmeticType|BidirectionalIndexType|StrideThroughGenerator|_SwiftNSDictionaryType|_SwiftNSEnumeratorType|BitwiseOperationsType|RandomAccessIndexType|NilLiteralConvertible|_ObjectiveCBridgeable|UnicodeDecodingResult|LazyForwardCollection|IntegerArithmeticType|MutableCollectionType|PermutationGenerator|MapSequenceGenerator|_UnsignedIntegerType|FilterCollectionView|UnsafeMutablePointer|UnsafeBufferPointer|UnsignedIntegerType|_SwiftNSCopyingType|DictionaryGenerator|_SignedIntegerType|_SwiftNSStringType|IntegerLiteralType|FilterSequenceView|EnumerateGenerator|BooleanLiteralType|HeapBufferStorage|EnumerateSequence|MirrorDisposition|_SignedNumberType|UnicodeScalarType|StringLiteralType|GeneratorSequence|_ForwardIndexType|StrideToGenerator|_SwiftNSArrayType|IndexingGenerator|_RawOptionSetType|FloatingPointType|MapCollectionView|SignedIntegerType|OutputStreamType|UnicodeCodecType|HalfOpenInterval|NSObjectProtocol|SignedNumberType|ObjectIdentifier|RawOptionSetType|_CocoaStringType|ForwardIndexType|RawRepresentable|MutableSliceable|FloatLiteralType|_ArrayBufferType|AbsoluteValuable|CFunctionPointer|QuickLookObject|MapSequenceView|EmptyCollection|FilterGenerator|_CollectionType|CollectionOfOne|ContiguousArray|DictionaryIndex|GeneratorOfOne|DebugPrintable|CVaListPointer|CUnsignedShort|COpaquePointer|EmptyGenerator|_Incrementable|RangeGenerator|NSErrorPointer|_Sequence_Type|ClosedInterval|CollectionType|ZipGenerator2|UnsafePointer|GeneratorType|StrideThrough|CUnsignedLong|UnicodeScalar|_SequenceType|LazySequence|IntervalType|SequenceType|StaticString|CUnsignedInt|_IntegerType|BooleanType|CVarArgType|_Strideable|_Comparable|GeneratorOf|IntegerType|Reflectable|CSignedChar|Streamable|SequenceOf|Dictionary|Comparable|HeapBuffer|_Sliceable|MirrorType|Strideable|CLongLong|CWideChar|Printable|Equatable|Unmanaged|Sliceable|Character|AnyObject|Optional|StrideTo|SinkType|AnyClass|Hashable|Selector|Float32|CChar16|UIntMax|Float80|Float64|RawByte|Process|CDouble|CChar32|UInt16|UInt32|C_ARGC|C_ARGV|UInt64|CFloat|String|SinkOf|Repeat|OnHeap|Double|CShort|IntMax|UTF16|Slice|CLong|UTF32|UInt8|Range|UWord|Array|Float|Int64|Int32|Int16|CBool|CChar|UInt|Int8|Word|UTF8|Zip2|Void|Bool|CInt|Any|Int|Bit)\b">
108 <token type="NameBuiltin"/>
109 </rule>
110 <rule pattern="(withUnsafeMutablePointers|withUnsafeMutablePointer|lexicographicalCompare|withExtendedLifetime|preconditionFailure|withUnsafePointers|underestimateCount|withUnsafePointer|assertionFailure|unsafeAddressOf|unsafeDowncast|countElements|unsafeBitCast|toDebugString|strideofValue|removeAtIndex|alignofValue|debugPrintln|precondition|sizeofValue|removeRange|numericCast|removeLast|debugPrint|fatalError|minElement|maxElement|startsWith|withVaList|partition|removeAll|transcode|dropFirst|enumerate|getVaList|strideof|contains|overlaps|dropLast|distance|toString|advance|println|alignof|reflect|indices|reverse|isEmpty|prefix|stride|sizeof|insert|assert|sorted|splice|filter|extend|reduce|suffix|equal|print|count|split|first|swap|dump|sort|lazy|last|join|find|abs|min|max|map)\b">
111 <token type="NameBuiltinPseudo"/>
112 </rule>
113 <rule pattern="\$\d+">
114 <token type="NameVariable"/>
115 </rule>
116 <rule pattern="0b[01_]+">
117 <token type="LiteralNumberBin"/>
118 </rule>
119 <rule pattern="0o[0-7_]+">
120 <token type="LiteralNumberOct"/>
121 </rule>
122 <rule pattern="0x[0-9a-fA-F_]+">
123 <token type="LiteralNumberHex"/>
124 </rule>
125 <rule pattern="[0-9][0-9_]*(\.[0-9_]+[eE][+\-]?[0-9_]+|\.[0-9_]*|[eE][+\-]?[0-9_]+)">
126 <token type="LiteralNumberFloat"/>
127 </rule>
128 <rule pattern="[0-9][0-9_]*">
129 <token type="LiteralNumberInteger"/>
130 </rule>
131 <rule pattern=""">
132 <token type="LiteralString"/>
133 <push state="string"/>
134 </rule>
135 <rule pattern="[(){}\[\].,:;=@#`?]|->|[<&?](?=\w)|(?<=\w)[>!?]">
136 <token type="Punctuation"/>
137 </rule>
138 <rule pattern="[/=\-+!*%<>&|^?~]+">
139 <token type="Operator"/>
140 </rule>
141 <rule pattern="[a-zA-Z_]\w*">
142 <token type="Name"/>
143 </rule>
144 </state>
145 <state name="comment-multi">
146 <rule>
147 <include state="comment"/>
148 </rule>
149 <rule pattern="[^*/]">
150 <token type="CommentMultiline"/>
151 </rule>
152 <rule pattern="/\*">
153 <token type="CommentMultiline"/>
154 <push/>
155 </rule>
156 <rule pattern="\*/">
157 <token type="CommentMultiline"/>
158 <pop depth="1"/>
159 </rule>
160 <rule pattern="[*/]">
161 <token type="CommentMultiline"/>
162 </rule>
163 </state>
164 <state name="keywords">
165 <rule pattern="(fallthrough|#selector|continue|default|repeat|switch|return|throw|catch|where|break|guard|defer|while|case|else|try|for|if|do|is|in|as)\b">
166 <token type="Keyword"/>
167 </rule>
168 <rule pattern="@availability\([^)]+\)">
169 <token type="KeywordReserved"/>
170 </rule>
171 <rule pattern="(@UIApplicationMain|@NSApplicationMain|@IBInspectable|@availability|@IBDesignable|associativity|@autoclosure|convenience|nonmutating|@NSManaged|@NSCopying|precedence|@IBAction|@noreturn|@IBOutlet|override|optional|mutating|indirect|Protocol|rethrows|required|willSet|dynamic|postfix|unowned|throws|prefix|didSet|final|inout|@objc|infix|right|lazy|none|weak|Type|left|get|set)\b">
172 <token type="KeywordReserved"/>
173 </rule>
174 <rule pattern="(as|dynamicType|false|is|nil|self|Self|super|true|__COLUMN__|__FILE__|__FUNCTION__|__LINE__|_|#(?:file|line|column|function))\b">
175 <token type="KeywordConstant"/>
176 </rule>
177 <rule pattern="import\b">
178 <token type="KeywordDeclaration"/>
179 <push state="module"/>
180 </rule>
181 <rule pattern="(class|enum|extension|struct|protocol)(\s+)([a-zA-Z_]\w*)">
182 <bygroups>
183 <token type="KeywordDeclaration"/>
184 <token type="Text"/>
185 <token type="NameClass"/>
186 </bygroups>
187 </rule>
188 <rule pattern="(func)(\s+)([a-zA-Z_]\w*)">
189 <bygroups>
190 <token type="KeywordDeclaration"/>
191 <token type="Text"/>
192 <token type="NameFunction"/>
193 </bygroups>
194 </rule>
195 <rule pattern="(var|let)(\s+)([a-zA-Z_]\w*)">
196 <bygroups>
197 <token type="KeywordDeclaration"/>
198 <token type="Text"/>
199 <token type="NameVariable"/>
200 </bygroups>
201 </rule>
202 <rule pattern="(typealias|extension|subscript|internal|protocol|operator|private|public|struct|deinit|static|import|class|init|func|enum|let|var)\b">
203 <token type="KeywordDeclaration"/>
204 </rule>
205 </state>
206 </rules>
207</lexer>
View as plain text