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:
parent
18f9b6f34e
commit
3eb0d71bd3
1 changed files with 82 additions and 31 deletions
|
@ -4,48 +4,99 @@ detect:
|
|||
filename: "\\.swift$"
|
||||
|
||||
rules:
|
||||
|
||||
# Patterns
|
||||
- type: \b(_)\b
|
||||
|
||||
# Operators
|
||||
- statement: "([.:;,+*|=!?\\%]|<|>|/|-|&)"
|
||||
- symbol.operator: ([.:;,+*|=!?\\%]|<|>|/|-|&)
|
||||
|
||||
# Statements
|
||||
- statement: "(class|import|let|var|struct|enum|func|if|else|switch|case|default|for|in|internal|external|unowned|private|public|throws)\\ "
|
||||
- statement: "(prefix|postfix|operator|extension|lazy|get|set|self|willSet|didSet|override|super|convenience|weak|strong|mutating|return|guard)\\ "
|
||||
# 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
|
||||
|
||||
# Keywords
|
||||
- statement: "(print)"
|
||||
- statement: "(init)"
|
||||
# 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
|
||||
|
||||
# Numbers
|
||||
- constant.number: "([0-9]+)"
|
||||
# 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
|
||||
|
||||
# Standard Types
|
||||
- type: "\\ ((U)?Int(8|16|32|64))"
|
||||
- constant: "(true|false|nil)"
|
||||
- type: "\\ (Double|String|Float|Boolean|Dictionary|Array|Int)"
|
||||
- type: "\\ (AnyObject)"
|
||||
# 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
|
||||
|
||||
# Meta
|
||||
- statement.meta: \@\b(autoclosure|available|convention|exported|IBAction|IBDesignable|IBOutlet|IBInspectable|infix)\b
|
||||
- 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
|
||||
|
||||
# Constant
|
||||
- constant: \b(true|false|nil)
|
||||
- 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
|
||||
|
||||
# Ctypes
|
||||
- type.ctypes: \b(CBool|CChar|CUnsignedChar|CShort|CUnsignedShort|CInt|CUnsignedInt|CLong|CUnsignedLong|CLongLong|CUnsignedLongLong|CWideChar|CChar16|CChar32|CFloat|CDouble)\b
|
||||
|
||||
# String
|
||||
- constant.string:
|
||||
start: "\""
|
||||
end: "\""
|
||||
skip: "\\\\."
|
||||
start: \"
|
||||
end: \"
|
||||
skip: \\.
|
||||
rules:
|
||||
- constant.specialChar: "\\\\."
|
||||
- constant.specialChar: (\\0|\\\\|\\t|\\n|\\r|\\"|\\')
|
||||
- constant.interpolation: \\\([[:graph:]]*\)
|
||||
- constant.unicode: \\u\{[[:xdigit:]]+}
|
||||
|
||||
- comment:
|
||||
start: "//"
|
||||
end: "$"
|
||||
rules:
|
||||
# Shebang Line
|
||||
- comment.shebang: ^(#!).*
|
||||
|
||||
# Todo
|
||||
- todo: "(TODO|XXX|FIXME):?"
|
||||
|
||||
- comment:
|
||||
start: "///"
|
||||
end: "$"
|
||||
rules:
|
||||
- todo: "(TODO|XXX|FIXME):?"
|
||||
# Doc Comment
|
||||
- comment.doc: (///).*
|
||||
|
||||
- comment:
|
||||
start: "/\\*\\*"
|
||||
# Line Comment
|
||||
- comment.line: "//.*"
|
||||
|
||||
# Block Comment
|
||||
- comment.block:
|
||||
start: "/\\*"
|
||||
end: "\\*/"
|
||||
rules:
|
||||
- todo: "(TODO|XXX|FIXME):?"
|
||||
|
||||
# Doc Block Comment
|
||||
- comment.block:
|
||||
start: "/\\*\\*"
|
||||
end: "\\*/"
|
||||
rules:
|
||||
- todo: "(TODO|XXX|FIXME):?"
|
||||
|
|
Loading…
Reference in a new issue