 TODO: Write a grammer of a path
 
 */
-public struct JSONPath: Equatable {
-
-    public enum Component: Equatable {
+public struct JSONPath {
+
+    public enum Component {
         case Text(String)
         case Numeric(Int64)
         case SelfReference
-
-        private func asTuple()-> (text: String?, number: Int64?, isSelfReference: Bool) {
-            switch self {
-            case .Text(let text):
-                return (text, nil, false)
-            case .Numeric(let number):
-                return (nil, number, false)
-            case .SelfReference:
-                return (nil, nil, true)
-            }
-        }
     }
 
     public let components: [Component]

        }
    }
}


//MARK:- Description

extension JSONPath: CustomDebugStringConvertible {
    
    public var debugDescription: String {
        var description = ""
        
        for component in components {
            switch component {
            case .Text(let text):
                description += "['\(text)']"
                break
                
            case .Numeric(let number):
                description += "[\(number)]"
                
            case .SelfReference:
                description += "[self]"
            }
        }
        
        return description
    }
}


//MARK:- String encoding

extension JSONPath {

    /**
    <#Description#>

    - parameter text: <#text description#>

    - returns: <#return value description#>
    */
    public static func encodeTextAsSubscriptPathComponent(text: String) -> String {
        let mutableText =  NSMutableString(string: text)
        //Note that the order of the replacements is significant. We must replace '`' first otherwise our replacements will get replaced.
        mutableText.replaceOccurrencesOfString("`", withString: "``", options: [], range: NSRange(location: 0, length: mutableText.length))
        mutableText.replaceOccurrencesOfString("'", withString: "`'", options: [], range: NSRange(location: 0, length: mutableText.length))

        return "['\(mutableText)']"
    }
}

            if stop { return }

            //Prepare for next loop
            componentIdx += 1

        } while !scanner.atEnd

