From 3c203e8f43d29fab7b0fc2b925ba202c7aafe85d Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Tue, 27 Oct 2015 16:11:45 -0400 Subject: [PATCH] Extract the key/term parser. --- prototype/Doubt/JSONParser.swift | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/prototype/Doubt/JSONParser.swift b/prototype/Doubt/JSONParser.swift index 6df7fb235..c6dd99f3c 100644 --- a/prototype/Doubt/JSONParser.swift +++ b/prototype/Doubt/JSONParser.swift @@ -47,10 +47,11 @@ typealias MembersParser = Parser.Function; // Parses an array of (String, CofreeJSON) object members func members(json: JSONParser) -> MembersParser { + let keyAndKeyTerm: Parser.Function = quoted --> { (_, range, key) in + (key, Cofree(range, .Leaf(.String(key)))) + } let pairs: Parser.Function = (curry(pair) <^> - (quoted --> { (_, range, key) -> (String, CofreeJSON) in - return (key, Cofree(range, .Leaf(.String(key)))) - }) + keyAndKeyTerm <* whitespace <* %":" <* whitespace