Debian Codegraph @

runtime/syntax/swift.yaml

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