]> git.lizzy.rs Git - micro.git/blob - runtime/syntax/swift.yaml
Ignore tool files
[micro.git] / runtime / syntax / swift.yaml
1 filetype: swift
2
3 detect:
4     filename: "\\.swift$"
5
6 rules:
7  
8     # Patterns
9     - type: \b(_)\b
10     
11     # Operators
12     - symbol.operator: ([.:;,+*|=!?\\%]|<|>|/|-|&)
13     
14     # Declaration Keywords
15     - statement.declaration: \b(associatedtype|class|deinit|enum|extension|fileprivate|func|import|init)\b
16     - statement.declaration: \b(inout|internal|let|open|operator|private|protocol|public|static|struct|subscript|typealias|var)\b
17     
18     # Statements Keywords
19     - statement: \b(break|case|continue|default|defer|do|else|fallthrough|for|guard)\b
20     - statement: \b(if|inif|repeat|return|switch|where|while)\b
21     
22     # keyword.reserved
23     - statement.reserved: \b(associativity|convenience|dynamic|didSet|final|get|infix|indirect|lazy|left|mutating)\b
24     - statement.reserved: \b(none|nonmutating|override|postfix|precedence|prefix|Protocol|required)\b
25     - statement.reserved: \b(right|set|Type|unowned|weak|willSet)\b
26     
27     # Expression and types
28     - type: \b(as|Any|catch|is|rethrows|super|self|throw|throws|try)\b
29     
30     - statement.built_in: \b(abs|advance|alignof|alignofValue|anyGenerator|assert|assertionFailure|bridgeFromObjectiveC)\b
31     - statement.built_in: \b(bridgeFromObjectiveCUnconditional|bridgeToObjectiveC|bridgeToObjectiveCUnconditional|contains)\b
32     - statement.built_in: \b(count|countElements|countLeadingZeros|debugPrint|debugPrintln|distance|dropFirst|dropLast|dump|encodeBitsAsWords)\b
33     - statement.built_in: \b(enumerate|equal|fatalError|filter|find|getBridgedObjectiveCType|getVaList|indices|insertionSort)\b
34     - statement.built_in: \b(isBridgedToObjectiveC|isBridgedVerbatimToObjectiveC|isUniquelyReferenced|isUniquelyReferencedNonObjC)\b
35     - statement.built_in: \b(join|lexicographicalCompare|map|max|maxElement|min|minElement|numericCast|overlaps|partition|posix)\b
36     - statement.built_in: \b(precondition|preconditionFailure|print|println|quickSort|readLine|reduce|reflect)\b
37     - statement.built_in: \b(reinterpretCast!reverse|roundUpToAlignment|sizeof|sizeofValue|sort|split|startsWith|stride)\b
38     - statement.built_in: \b(strideof|strideofValue|swap|toString|transcode|underestimateCount|unsafeAddressOf|unsafeBitCast)\b
39     - statement.built_in: \b(unsafeDowncast|unsafeUnwrap|unsafeReflect|withExtendedLifetime|withObjectAtPlusZero|withUnsafePointer)\b
40     - statement.built_in: \b(withUnsafePointerToObject|withUnsafeMutablePointer|withUnsafeMutablePointers|withUnsafePointer)\b
41     - statement.built_in: \b(withUnsafePointers|withVaList|zip)\b
42
43     # Meta
44     - statement.meta: \@\b(autoclosure|available|convention|exported|IBAction|IBDesignable|IBOutlet|IBInspectable|infix)\b
45     - statement.meta: \@\b(lazy|noreturn|noescape|nonobjc|NSApplicationMain|NSCopying|NSManaged|objc|prefix|postfix)\b
46     - statement.meta: \@\b(required|testable|warn_unused_result|UIApplicationMain)\b
47   
48     #preprocessor
49     - preproc: ^[[:space:]]*#[[:space:]]*(define|else|elseif|endif|if|selector)\b
50     - preproc.DebugIdentifier: \b(__COLUMN__|__FILE__|__FUNCTION__|__LINE__)\b
51     - preproc.DebugIdentifier: ^[[:space:]]*#[[:space:]]*(column|file|function|line)\b
52
53     # Constant
54     - constant: \b(true|false|nil)
55     - constant.number: ([0-9]+)
56     
57     # Storage Types
58     - type.storage: \b((U)?Int(8|16|32|64))\b
59     - type.storage: \b(Int|UInt|String|Bit|Bool|Character|Double|Optional|Float|Range)\b
60     - type.storage: \b(AnyObject)\b
61     
62     # Collections
63     - type.collections: \b(Array|Dictionary|Set)\b
64
65     # Ctypes
66     - type.ctypes: \b(CBool|CChar|CUnsignedChar|CShort|CUnsignedShort|CInt|CUnsignedInt|CLong|CUnsignedLong|CLongLong|CUnsignedLongLong|CWideChar|CChar16|CChar32|CFloat|CDouble)\b
67
68     # String
69     - constant.string:
70         start: \"
71         end: \"
72         skip: \\.
73         rules:
74             - constant.specialChar: (\\0|\\\\|\\t|\\n|\\r|\\"|\\')
75             - constant.interpolation: \\\([[:graph:]]*\)
76             - constant.unicode: \\u\{[[:xdigit:]]+}
77
78     # Shebang Line
79     - comment.shebang: ^(#!).*
80
81     # Doc Comment
82     - comment.doc: (///).*
83     
84     # Line Comment
85     - comment.line: "//.*"
86     
87     # Block Comment
88     - comment.block:
89         start: "/\\*"
90         end: "\\*/"
91         rules:
92             - todo: "(TODO|XXX|FIXME):?"
93       
94     # Doc Block Comment
95     - comment.block:
96         start: "/\\*\\*"
97         end: "\\*/"
98         rules:
99             - todo: "(TODO|XXX|FIXME):?"
100
101     # Todo
102     - todo: "(TODO|XXX|FIXME):?"