Updated swift syntax yaml file as missing keywords and some highlighting not working correctly. (#644)

* Updated the keywords and micros

* updated keywords  and  interpolation and unicode added to string

* add test swift file

* Delete swift-test.swift

delete swift test file
This commit is contained in:
Tommy 2017-05-05 20:14:50 +01:00 committed by Zachary Yedidia
parent 18f9b6f34e
commit 3eb0d71bd3

View file

@ -4,48 +4,99 @@ detect:
filename: "\\.swift$" filename: "\\.swift$"
rules: rules:
# Patterns
- type: \b(_)\b
# Operators # Operators
- statement: "([.:;,+*|=!?\\%]|<|>|/|-|&)" - symbol.operator: ([.:;,+*|=!?\\%]|<|>|/|-|&)
# Declaration Keywords
- statement.declaration: \b(associatedtype|class|deinit|enum|extension|fileprivate|func|import|init)\b
- statement.declaration: \b(inout|internal|let|open|operator|private|protocol|public|static|struct|subscript|typealias|var)\b
# Statements Keywords
- statement: \b(break|case|continue|default|defer|do|else|fallthrough|for|guard)\b
- statement: \b(if|inif|repeat|return|switch|where|while)\b
# keyword.reserved
- statement.reserved: \b(associativity|convenience|dynamic|didSet|final|get|infix|indirect|lazy|left|mutating)\b
- statement.reserved: \b(none|nonmutating|override|postfix|precedence|prefix|Protocol|required)\b
- statement.reserved: \b(right|set|Type|unowned|weak|willSet)\b
# Expression and types
- type: \b(as|Any|catch|is|rethrows|super|self|throw|throws|try)\b
- statement.built_in: \b(abs|advance|alignof|alignofValue|anyGenerator|assert|assertionFailure|bridgeFromObjectiveC)\b
- statement.built_in: \b(bridgeFromObjectiveCUnconditional|bridgeToObjectiveC|bridgeToObjectiveCUnconditional|contains)\b
- statement.built_in: \b(count|countElements|countLeadingZeros|debugPrint|debugPrintln|distance|dropFirst|dropLast|dump|encodeBitsAsWords)\b
- statement.built_in: \b(enumerate|equal|fatalError|filter|find|getBridgedObjectiveCType|getVaList|indices|insertionSort)\b
- statement.built_in: \b(isBridgedToObjectiveC|isBridgedVerbatimToObjectiveC|isUniquelyReferenced|isUniquelyReferencedNonObjC)\b
- statement.built_in: \b(join|lexicographicalCompare|map|max|maxElement|min|minElement|numericCast|overlaps|partition|posix)\b
- statement.built_in: \b(precondition|preconditionFailure|print|println|quickSort|readLine|reduce|reflect)\b
- statement.built_in: \b(reinterpretCast!reverse|roundUpToAlignment|sizeof|sizeofValue|sort|split|startsWith|stride)\b
- statement.built_in: \b(strideof|strideofValue|swap|toString|transcode|underestimateCount|unsafeAddressOf|unsafeBitCast)\b
- statement.built_in: \b(unsafeDowncast|unsafeUnwrap|unsafeReflect|withExtendedLifetime|withObjectAtPlusZero|withUnsafePointer)\b
- statement.built_in: \b(withUnsafePointerToObject|withUnsafeMutablePointer|withUnsafeMutablePointers|withUnsafePointer)\b
- statement.built_in: \b(withUnsafePointers|withVaList|zip)\b
# Statements # Meta
- statement: "(class|import|let|var|struct|enum|func|if|else|switch|case|default|for|in|internal|external|unowned|private|public|throws)\\ " - statement.meta: \@\b(autoclosure|available|convention|exported|IBAction|IBDesignable|IBOutlet|IBInspectable|infix)\b
- statement: "(prefix|postfix|operator|extension|lazy|get|set|self|willSet|didSet|override|super|convenience|weak|strong|mutating|return|guard)\\ " - statement.meta: \@\b(lazy|noreturn|noescape|nonobjc|NSApplicationMain|NSCopying|NSManaged|objc|prefix|postfix)\b
- statement.meta: \@\b(required|testable|warn_unused_result|UIApplicationMain)\b
#preprocessor
- preproc: ^[[:space:]]*#[[:space:]]*(define|else|elseif|endif|if|selector)\b
- preproc.DebugIdentifier: \b(__COLUMN__|__FILE__|__FUNCTION__|__LINE__)\b
- preproc.DebugIdentifier: ^[[:space:]]*#[[:space:]]*(column|file|function|line)\b
# Keywords # Constant
- statement: "(print)" - constant: \b(true|false|nil)
- statement: "(init)" - constant.number: ([0-9]+)
# Storage Types
- type.storage: \b((U)?Int(8|16|32|64))\b
- type.storage: \b(Int|UInt|String|Bit|Bool|Character|Double|Optional|Float|Range)\b
- type.storage: \b(AnyObject)\b
# Collections
- type.collections: \b(Array|Dictionary|Set)\b
# Numbers # Ctypes
- constant.number: "([0-9]+)" - type.ctypes: \b(CBool|CChar|CUnsignedChar|CShort|CUnsignedShort|CInt|CUnsignedInt|CLong|CUnsignedLong|CLongLong|CUnsignedLongLong|CWideChar|CChar16|CChar32|CFloat|CDouble)\b
# Standard Types
- type: "\\ ((U)?Int(8|16|32|64))"
- constant: "(true|false|nil)"
- type: "\\ (Double|String|Float|Boolean|Dictionary|Array|Int)"
- type: "\\ (AnyObject)"
# String
- constant.string: - constant.string:
start: "\"" start: \"
end: "\"" end: \"
skip: "\\\\." skip: \\.
rules: rules:
- constant.specialChar: "\\\\." - constant.specialChar: (\\0|\\\\|\\t|\\n|\\r|\\"|\\')
- constant.interpolation: \\\([[:graph:]]*\)
- constant.unicode: \\u\{[[:xdigit:]]+}
- comment: # Shebang Line
start: "//" - comment.shebang: ^(#!).*
end: "$"
# Todo
- todo: "(TODO|XXX|FIXME):?"
# Doc Comment
- comment.doc: (///).*
# Line Comment
- comment.line: "//.*"
# Block Comment
- comment.block:
start: "/\\*"
end: "\\*/"
rules: rules:
- todo: "(TODO|XXX|FIXME):?" - todo: "(TODO|XXX|FIXME):?"
- comment: # Doc Block Comment
start: "///" - comment.block:
end: "$"
rules:
- todo: "(TODO|XXX|FIXME):?"
- comment:
start: "/\\*\\*" start: "/\\*\\*"
end: "\\*/" end: "\\*/"
rules: rules:
- todo: "(TODO|XXX|FIXME):?" - todo: "(TODO|XXX|FIXME):?"