'(?#+)"""(?s:.*?)"""\k|(?#+)"(?:[^"\n]|"(?!\k))*"\k', 'class' => 'string'], // 複数行の文字列 """…""" ['re' => '"""(?s:.*?)(?:"""|\z)', 'class' => 'string'], // コンパイラ指令(#if, #available, #selector等) ['re' => '#[A-Za-z_]\w*', 'class' => 'preprocessor'], // 属性(@main, @MainActor, @escaping等) ['re' => '@[A-Za-z_]\w*', 'class' => 'attribute'], // 予約語を名前にする `default` ['re' => '`[^`\n]+`', 'class' => null], ]; protected array $tokens = [ 'keyword' => [ // 宣言 'associatedtype', 'class', 'deinit', 'enum', 'extension', 'fileprivate', 'func', 'import', 'init', 'inout', 'internal', 'let', 'open', 'operator', 'private', 'precedencegroup', 'protocol', 'public', 'rethrows', 'static', 'struct', 'subscript', 'typealias', 'var', 'actor', 'macro', 'package', 'nonisolated', 'isolated', 'consuming', 'borrowing', 'sending', // 文 'break', 'case', 'catch', 'continue', 'default', 'defer', 'do', 'else', 'fallthrough', 'for', 'guard', 'if', 'in', 'repeat', 'return', 'throw', 'switch', 'where', 'while', // 式・型 'as', 'await', 'is', 'self', 'Self', 'super', 'throws', 'try', 'async', 'some', 'any', 'Type', 'Protocol', // 文脈依存 'convenience', 'dynamic', 'didSet', 'final', 'get', 'indirect', 'lazy', 'mutating', 'nonmutating', 'optional', 'override', 'postfix', 'prefix', 'infix', 'required', 'set', 'unowned', 'weak', 'willSet', ], 'constant' => [ 'true', 'false', 'nil', ], 'type' => [ 'Int', 'Int8', 'Int16', 'Int32', 'Int64', 'Int128', 'UInt', 'UInt8', 'UInt16', 'UInt32', 'UInt64', 'UInt128', 'Float', 'Float16', 'Float32', 'Float64', 'Float80', 'Double', 'CGFloat', 'Bool', 'String', 'Substring', 'Character', 'Array', 'ContiguousArray', 'Dictionary', 'Set', 'Optional', 'Result', 'Range', 'ClosedRange', 'Void', 'Never', 'Any', 'AnyObject', 'Error', 'Equatable', 'Hashable', 'Comparable', 'Codable', 'Encodable', 'Decodable', 'Identifiable', 'Sendable', 'Sequence', 'Collection', 'IteratorProtocol', 'CustomStringConvertible', 'Numeric', 'BinaryInteger', 'FloatingPoint', 'SIMD2', 'SIMD3', 'SIMD4', 'UnsafePointer', 'UnsafeMutablePointer', 'UnsafeRawPointer', 'UnsafeMutableRawPointer', 'UnsafeBufferPointer', 'OpaquePointer', 'Data', 'Date', 'URL', 'UUID', 'NSObject', 'Task', 'MainActor', 'View', 'some', ], 'builtin' => [ 'print', 'debugPrint', 'dump', 'assert', 'assertionFailure', 'precondition', 'preconditionFailure', 'fatalError', 'min', 'max', 'abs', 'stride', 'zip', 'sequence', 'repeatElement', 'swap', 'type', 'withUnsafePointer', 'withUnsafeMutablePointer', 'withUnsafeBytes', 'withExtendedLifetime', 'MemoryLayout', 'readLine', 'numericCast', ], ]; }