0001 public enum Yaml{ 0002 case Null
Parser.swift:5 let aliases: [String: Yaml]Parser.swift:7 init (_ tokens: [TokenMatch], _ aliases: [String: Yaml] = [:]) {Parser.swift:13 typealias ContextValue = (context: Context, value: Yaml)Parser.swift:14 func createContextValue (context: Context) -> Yaml -> ContextValue {Parser.swift:20 func getValue (cv: ContextValue) -> Yaml {Parser.swift:24 func parseDoc (tokens: [TokenMatch]) -> Result<Yaml> {Parser.swift:35 func parseDocs (tokens: [TokenMatch]) -> Result<[Yaml]> {Parser.swift:39 func parseDocs (acc: [Yaml]) -> Context -> Result<[Yaml]> {Parser.swift:39 func parseDocs (acc: [Yaml]) -> Context -> Result<[Yaml]> {Parser.swift:164 let v = Yaml.Int(parseInt(m, radix: 10))Parser.swift:170 let v = Yaml.Int(parseInt(m, radix: 8))Parser.swift:176 let v = Yaml.Int(parseInt(m, radix: 16))Parser.swift:181 let v = Yaml.Int(parseInt(m, radix: 60))Parser.swift:220 >>- { value in Yaml.String(foldBlock(value.string ?? "")) }Parser.swift:257 func addAlias (name: String) -> Yaml -> Context -> Context {Parser.swift:267 func appendToArray (array: [Yaml]) -> Yaml -> [Yaml] {Parser.swift:267 func appendToArray (array: [Yaml]) -> Yaml -> [Yaml] {Parser.swift:267 func appendToArray (array: [Yaml]) -> Yaml -> [Yaml] {Parser.swift:273 func putToMap (map: [Yaml: Yaml]) -> Yaml -> Yaml -> [Yaml: Yaml] {Parser.swift:273 func putToMap (map: [Yaml: Yaml]) -> Yaml -> Yaml -> [Yaml: Yaml] {Parser.swift:273 func putToMap (map: [Yaml: Yaml]) -> Yaml -> Yaml -> [Yaml: Yaml] {Parser.swift:273 func putToMap (map: [Yaml: Yaml]) -> Yaml -> Yaml -> [Yaml: Yaml] {Parser.swift:273 func putToMap (map: [Yaml: Yaml]) -> Yaml -> Yaml -> [Yaml: Yaml] {Parser.swift:273 func putToMap (map: [Yaml: Yaml]) -> Yaml -> Yaml -> [Yaml: Yaml] {Parser.swift:283 func checkKeyUniqueness (acc: [Yaml: Yaml]) -> (context: Context, key: Yaml)Parser.swift:283 func checkKeyUniqueness (acc: [Yaml: Yaml]) -> (context: Context, key: Yaml)Parser.swift:283 func checkKeyUniqueness (acc: [Yaml: Yaml]) -> (context: Context, key: Yaml)Parser.swift:298 func parseFlowSeq (acc: [Yaml]) -> Context -> Result<ContextValue> {Parser.swift:323 func parseFlowMap (acc: [Yaml: Yaml]) -> Context -> Result<ContextValue> {Parser.swift:323 func parseFlowMap (acc: [Yaml: Yaml]) -> Context -> Result<ContextValue> {Parser.swift:352 func parseBlockSeq (acc: [Yaml]) -> Context -> Result<ContextValue> {Parser.swift:377 func parseBlockMap (acc: [Yaml: Yaml]) -> Context -> Result<ContextValue> {Parser.swift:377 func parseBlockMap (acc: [Yaml: Yaml]) -> Context -> Result<ContextValue> {Parser.swift:393 func parseQuestionMarkKeyValue (acc: [Yaml: Yaml]) -> Context -> Result<ContextValue> {Parser.swift:393 func parseQuestionMarkKeyValue (acc: [Yaml: Yaml]) -> Context -> Result<ContextValue> {Parser.swift:427 func parseStringKeyValue (acc: [Yaml: Yaml]) -> Context -> Result<ContextValue> {Parser.swift:427 func parseStringKeyValue (acc: [Yaml: Yaml]) -> Context -> Result<ContextValue> {Yaml.swift:7 case Array([Yaml])Yaml.swift:8 case Dictionary([Yaml: Yaml])Yaml.swift:8 case Dictionary([Yaml: Yaml])Yaml.swift:11 extension Yaml: NilLiteralConvertible {Yaml.swift:17 extension Yaml: BooleanLiteralConvertible {Yaml.swift:23 extension Yaml: IntegerLiteralConvertible {Yaml.swift:29 extension Yaml: FloatLiteralConvertible {Yaml.swift:35 extension Yaml: StringLiteralConvertible {Yaml.swift:49 extension Yaml: ArrayLiteralConvertible {Yaml.swift:50 public init(arrayLiteral elements: Yaml...) {Yaml.swift:51 var array = [Yaml]()Yaml.swift:60 extension Yaml: DictionaryLiteralConvertible {Yaml.swift:61 public init(dictionaryLiteral elements: (Yaml, Yaml)...) {Yaml.swift:61 public init(dictionaryLiteral elements: (Yaml, Yaml)...) {Yaml.swift:62 var dictionary = [Yaml: Yaml]()Yaml.swift:62 var dictionary = [Yaml: Yaml]()Yaml.swift:70 extension Yaml: CustomStringConvertible {Yaml.swift:91 extension Yaml: Hashable {Yaml.swift:97 extension Yaml {Yaml.swift:98 public static func load (text: Swift.String) -> Result<Yaml> {Yaml.swift:102 public static func loadMultiple (text: Swift.String) -> Result<[Yaml]> {Yaml.swift:106 public static func debug (text: Swift.String) -> Result<Yaml> {Yaml.swift:110 >>- { value -> Yaml in print("------ Doc:\n\(value)"); return value }Yaml.swift:117 public static func debugMultiple (text: Swift.String) -> Result<[Yaml]> {Yaml.swift:121 >>- { values -> [Yaml] in values.forEach {Yaml.swift:131 extension Yaml {Yaml.swift:151 let empty = [Yaml](count: emptyCount, repeatedValue: .Null)Yaml.swift:157 var array = [Yaml](count: index + 1, repeatedValue: .Null)Yaml.swift:180 var dictionary = [Yaml: Yaml]()Yaml.swift:180 var dictionary = [Yaml: Yaml]()Yaml.swift:188 extension Yaml {Yaml.swift:233 public var array: [Yaml]? {Yaml.swift:242 public var dictionary: [Yaml: Yaml]? {Yaml.swift:242 public var dictionary: [Yaml: Yaml]? {Yaml.swift:263 public func == (lhs: Yaml, rhs: Yaml) -> Bool {Yaml.swift:263 public func == (lhs: Yaml, rhs: Yaml) -> Bool {Yaml.swift:338 public func != (lhs: Yaml, rhs: Yaml) -> Bool {Yaml.swift:338 public func != (lhs: Yaml, rhs: Yaml) -> Bool {Yaml.swift:343 public prefix func - (value: Yaml) -> Yaml {Yaml.swift:343 public prefix func - (value: Yaml) -> Yaml {0003 case Bool
Yaml.swift:13 self = .NullYaml.swift:73 case .Null:Yaml.swift:140 return .NullYaml.swift:143 return .NullYaml.swift:151 let empty = [Yaml](count: emptyCount, repeatedValue: .Null)Yaml.swift:157 var array = [Yaml](count: index + 1, repeatedValue: .Null)Yaml.swift:168 return dictionary[key] ?? .NullYaml.swift:170 return .NullYaml.swift:266 case .Null:Yaml.swift:268 case .Null:(Swift.Bool) 0004 case Int
Yaml.swift:19 self = .Bool(booleanLiteral)Yaml.swift:75 case .Bool(let b):Yaml.swift:191 case .Bool(let b):Yaml.swift:274 case .Bool(let lv):Yaml.swift:276 case .Bool(let rv):(Swift.Int) 0005 case Double
Parser.swift:164 let v = Yaml.Int(parseInt(m, radix: 10))Parser.swift:170 let v = Yaml.Int(parseInt(m, radix: 8))Parser.swift:176 let v = Yaml.Int(parseInt(m, radix: 16))Parser.swift:181 let v = Yaml.Int(parseInt(m, radix: 60))Yaml.swift:25 self = .Int(integerLiteral)Yaml.swift:77 case .Int(let i):Yaml.swift:200 case .Int(let i):Yaml.swift:217 case .Int(let i):Yaml.swift:282 case .Int(let lv):Yaml.swift:284 case .Int(let rv):Yaml.swift:296 case .Int(let rv):Yaml.swift:345 case .Int(let v):Yaml.swift:346 return .Int(-v)(Swift.Double) 0006 case String
Parser.swift:185 return lift((advance(context), .Double(Double.infinity)))Parser.swift:188 return lift((advance(context), .Double(-Double.infinity)))Parser.swift:191 return lift((advance(context), .Double(Double.NaN)))Parser.swift:195 return lift((advance(context), .Double(m.doubleValue)))Yaml.swift:31 self = .Double(floatLiteral)Yaml.swift:79 case .Double(let f):Yaml.swift:202 case .Double(let f):Yaml.swift:215 case .Double(let f):Yaml.swift:286 case .Double(let rv):Yaml.swift:292 case .Double(let lv):Yaml.swift:294 case .Double(let rv):Yaml.swift:347 case .Double(let v):Yaml.swift:348 return .Double(-v)(Swift.String) 0007 case Array
Parser.swift:220 >>- { value in Yaml.String(foldBlock(value.string ?? "")) }Parser.swift:452 return lift((advance(context), .String(folded)))Parser.swift:456 return lift((advance(context), .String(unescapeDoubleQuotes(foldFlow(m)))))Parser.swift:460 return lift((advance(context), .String(unescapeSingleQuotes(foldFlow(m)))))Parser.swift:533 >>- { context in (context, .String(trimmed))}Yaml.swift:37 self = .String(stringLiteral)Yaml.swift:41 self = .String(extendedGraphemeClusterLiteral)Yaml.swift:45 self = .String(unicodeScalarLiteral)Yaml.swift:81 case .String(let s):Yaml.swift:226 case .String(let s):Yaml.swift:302 case .String(let lv):Yaml.swift:304 case .String(let rv):([Yaml]) 0008 case Dictionary
Parser.swift:301 return lift((advance(context), .Array(acc)))Parser.swift:355 return lift((context, .Array(acc)))Yaml.swift:56 self = .Array(array)Yaml.swift:83 case .Array(let s):Yaml.swift:136 case .Array(let array):Yaml.swift:149 case .Array(let array):Yaml.swift:155 self = .Array(new)Yaml.swift:159 self = .Array(array)Yaml.swift:235 case .Array(let array):Yaml.swift:253 case .Array(let array):Yaml.swift:310 case .Array(let lv):Yaml.swift:312 case .Array(let rv) where lv.count == rv.count:([Yaml: Yaml]) 0009 } 0010 0011 extension Yaml: NilLiteralConvertible { 0012 public init(nilLiteral: ()) { 0013 self = .Null 0014 } 0015 } 0016 0017 extension Yaml: BooleanLiteralConvertible { 0018 public init(booleanLiteral: BooleanLiteralType) { 0019 self = .Bool(booleanLiteral) 0020 } 0021 } 0022 0023 extension Yaml: IntegerLiteralConvertible { 0024 public init(integerLiteral: IntegerLiteralType) { 0025 self = .Int(integerLiteral) 0026 } 0027 } 0028 0029 extension Yaml: FloatLiteralConvertible { 0030 public init(floatLiteral: FloatLiteralType) { 0031 self = .Double(floatLiteral) 0032 } 0033 } 0034 0035 extension Yaml: StringLiteralConvertible { 0036 public init(stringLiteral: StringLiteralType) { 0037 self = .String(stringLiteral) 0038 } 0039 0040 public init(extendedGraphemeClusterLiteral: StringLiteralType) { 0041 self = .String(extendedGraphemeClusterLiteral) 0042 } 0043 0044 public init(unicodeScalarLiteral: StringLiteralType) { 0045 self = .String(unicodeScalarLiteral) 0046 } 0047 } 0048 0049 extension Yaml: ArrayLiteralConvertible { 0050 public init(arrayLiteral elements: Yaml...) { 0051 var array = [Yaml]() 0052 array.reserveCapacity(elements.count) 0053 for element in elements { 0054 array.append(element) 0055 } 0056 self = .Array(array) 0057 } 0058 } 0059 0060 extension Yaml: DictionaryLiteralConvertible { 0061 public init(dictionaryLiteral elements: (Yaml, Yaml)...) { 0062 var dictionary = [Yaml: Yaml]() 0063 for (k, v) in elements { 0064 dictionary[k] = v 0065 } 0066 self = .Dictionary(dictionary) 0067 } 0068 } 0069 0070 extension Yaml: CustomStringConvertible { 0071 public var description
Parser.swift:326 return lift((advance(context), .Dictionary(acc)))Parser.swift:388 return lift((context, .Dictionary(acc)))Yaml.swift:66 self = .Dictionary(dictionary)Yaml.swift:85 case .Dictionary(let m):Yaml.swift:167 case .Dictionary(let dictionary):Yaml.swift:175 case .Dictionary(let dictionary):Yaml.swift:178 self = .Dictionary(new)Yaml.swift:182 self = .Dictionary(dictionary)Yaml.swift:244 case .Dictionary(let dictionary):Yaml.swift:255 case .Dictionary(let dictionary):Yaml.swift:323 case .Dictionary(let lv):Yaml.swift:325 case .Dictionary(let rv) where lv.count == rv.count:: Swift.String { 0072 switch self { 0073 case .Null: 0074 return "Null" 0075 case .Bool(let b): 0076 return "Bool(\(b))" 0077 case .Int(let i): 0078 return "Int(\(i))" 0079 case .Double(let f): 0080 return "Double(\(f))" 0081 case .String(let s): 0082 return "String(\(s))" 0083 case .Array(let s): 0084 return "Array(\(s))" 0085 case .Dictionary(let m): 0086 return "Dictionary(\(m))" 0087 } 0088 } 0089 } 0090 0091 extension Yaml: Hashable { 0092 public var hashValue: Swift.Int { 0093 return description.hashValue 0094 } 0095 } 0096 0097 extension Yaml { 0098 public static func load (text: Swift.String) -> Result<Yaml> { 0099 return tokenize(text) >>=- parseDoc 0100 } 0101 0102 public static func loadMultiple (text: Swift.String) -> Result<[Yaml]> { 0103 return tokenize(text) >>=- parseDocs 0104 } 0105 0106 public static func debug (text: Swift.String) -> Result<Yaml> { 0107 let result = tokenize(text) 0108 >>- { tokens in print("\n====== Tokens:\n\(tokens)"); return tokens } 0109 >>=- parseDoc 0110 >>- { value -> Yaml in print("------ Doc:\n\(value)"); return value } 0111 if let error = result.error { 0112 print("~~~~~~\n\(error)") 0113 } 0114 return result 0115 } 0116 0117 public static func debugMultiple (text: Swift.String) -> Result<[Yaml]> { 0118 let result = tokenize(text) 0119 >>- { tokens in print("\n====== Tokens:\n\(tokens)"); return tokens } 0120 >>=- parseDocs 0121 >>- { values -> [Yaml] in values.forEach { 0122 v in print("------ Doc:\n\(v)") 0123 }; return values } 0124 if let error = result.error { 0125 print("~~~~~~\n\(error)") 0126 } 0127 return result 0128 } 0129 } 0130 0131 extension Yaml { 0132 public subscript(index: Swift.Int) -> Yaml { 0133 get { 0134 assert(index >= 0) 0135 switch self { 0136 case .Array(let array): 0137 if index >= array.startIndex && index < array.endIndex { 0138 return array[index] 0139 } else { 0140 return .Null 0141 } 0142 default: 0143 return .Null 0144 } 0145 } 0146 set { 0147 assert(index >= 0) 0148 switch self { 0149 case .Array(let array): 0150 let emptyCount = max(0, index + 1 - array.count) 0151 let empty = [Yaml](count: emptyCount, repeatedValue: .Null) 0152 var new = array 0153 new.appendContentsOf(empty) 0154 new[index] = newValue 0155 self = .Array(new) 0156 default: 0157 var array = [Yaml](count: index + 1, repeatedValue: .Null) 0158 array[index] = newValue 0159 self = .Array(array) 0160 } 0161 } 0162 } 0163 0164 public subscript(key: Yaml) -> Yaml { 0165 get { 0166 switch self { 0167 case .Dictionary(let dictionary): 0168 return dictionary[key] ?? .Null 0169 default: 0170 return .Null 0171 } 0172 } 0173 set { 0174 switch self { 0175 case .Dictionary(let dictionary): 0176 var new = dictionary 0177 new[key] = newValue 0178 self = .Dictionary(new) 0179 default: 0180 var dictionary = [Yaml: Yaml]() 0181 dictionary[key] = newValue 0182 self = .Dictionary(dictionary) 0183 } 0184 } 0185 } 0186 } 0187 0188 extension Yaml { 0189 public var bool: Swift.Bool? { 0190 switch self { 0191 case .Bool(let b): 0192 return b 0193 default: 0194 return nil 0195 } 0196 } 0197 0198 public var int: Swift.Int? { 0199 switch self { 0200 case .Int(let i): 0201 return i 0202 case .Double(let f): 0203 if Swift.Double(Swift.Int(f)) == f { 0204 return Swift.Int(f) 0205 } else { 0206 return nil 0207 } 0208 default: 0209 return nil 0210 } 0211 } 0212 0213 public var double: Swift.Double? { 0214 switch self { 0215 case .Double(let f): 0216 return f 0217 case .Int(let i): 0218 return Swift.Double(i) 0219 default: 0220 return nil 0221 } 0222 } 0223 0224 public var string
Yaml.swift:93 return description.hashValue: Swift.String? { 0225 switch self { 0226 case .String(let s): 0227 return s 0228 default: 0229 return nil 0230 } 0231 } 0232 0233 public var array: [Yaml]? { 0234 switch self { 0235 case .Array(let array): 0236 return array 0237 default: 0238 return nil 0239 } 0240 } 0241 0242 public var dictionary: [Yaml: Yaml]? { 0243 switch self { 0244 case .Dictionary(let dictionary): 0245 return dictionary 0246 default: 0247 return nil 0248 } 0249 } 0250 0251 public var count: Swift.Int? { 0252 switch self { 0253 case .Array(let array): 0254 return array.count 0255 case .Dictionary(let dictionary): 0256 return dictionary.count 0257 default: 0258 return nil 0259 } 0260 } 0261 } 0262 0263 public func == (lhs: Yaml, rhs: Yaml) -> Bool { 0264 switch lhs { 0265 0266 case .Null: 0267 switch rhs { 0268 case .Null: 0269 return true 0270 default: 0271 return false 0272 } 0273 0274 case .Bool(let lv): 0275 switch rhs { 0276 case .Bool(let rv): 0277 return lv == rv 0278 default: 0279 return false 0280 } 0281 0282 case .Int(let lv): 0283 switch rhs { 0284 case .Int(let rv): 0285 return lv == rv 0286 case .Double(let rv): 0287 return Double(lv) == rv 0288 default: 0289 return false 0290 } 0291 0292 case .Double(let lv): 0293 switch rhs { 0294 case .Double(let rv): 0295 return lv == rv 0296 case .Int(let rv): 0297 return lv == Double(rv) 0298 default: 0299 return false 0300 } 0301 0302 case .String(let lv): 0303 switch rhs { 0304 case .String(let rv): 0305 return lv == rv 0306 default: 0307 return false 0308 } 0309 0310 case .Array(let lv): 0311 switch rhs { 0312 case .Array(let rv) where lv.count == rv.count: 0313 for i in 0..<lv.count { 0314 if lv[i] != rv[i] { 0315 return false 0316 } 0317 } 0318 return true 0319 default: 0320 return false 0321 } 0322 0323 case .Dictionary(let lv): 0324 switch rhs { 0325 case .Dictionary(let rv) where lv.count == rv.count: 0326 for (k, v) in lv { 0327 if rv[k] == nil || rv[k] != v { 0328 return false 0329 } 0330 } 0331 return true 0332 default: 0333 return false 0334 } 0335 } 0336 } 0337 0338 public func != (lhs: Yaml, rhs: Yaml) -> Bool { 0339 return !(lhs == rhs) 0340 } 0341 0342 // unary `-` operator 0343 public prefix func - (value: Yaml) -> Yaml { 0344 switch value { 0345 case .Int(let v): 0346 return .Int(-v) 0347 case .Double(let v): 0348 return .Double(-v) 0349 default: 0350 fatalError("`-` operator may only be used on .Int or .Double Yaml values") 0351 } 0352 } 0353
Parser.swift:220 >>- { value in Yaml.String(foldBlock(value.string ?? "")) }