1
1
mirror of https://github.com/github/semantic.git synced 2024-12-26 16:33:03 +03:00

Extract the key/term parser.

This commit is contained in:
Rob Rix 2015-10-27 16:11:45 -04:00
parent c366e379a0
commit 3c203e8f43

View File

@ -47,10 +47,11 @@ typealias MembersParser = Parser<String, [(String, CofreeJSON)]>.Function;
// Parses an array of (String, CofreeJSON) object members
func members(json: JSONParser) -> MembersParser {
let keyAndKeyTerm: Parser<String, (String, CofreeJSON)>.Function = quoted --> { (_, range, key) in
(key, Cofree(range, .Leaf(.String(key))))
}
let pairs: Parser<String, (String, CofreeJSON)>.Function = (curry(pair) <^>
(quoted --> { (_, range, key) -> (String, CofreeJSON) in
return (key, Cofree(range, .Leaf(.String(key))))
})
keyAndKeyTerm
<* whitespace
<* %":"
<* whitespace