1
1
mirror of https://github.com/github/semantic.git synced 2024-11-25 11:04:00 +03:00

Syntax nodes’ JSON is unambiguous.

This commit is contained in:
Rob Rix 2015-10-23 18:22:24 -04:00
parent 48a8217c41
commit 155b0a16ef

View File

@ -105,11 +105,11 @@ extension Syntax {
public func JSON(@noescape leaf leaf: A -> Doubt.JSON, @noescape recur: Recur -> Doubt.JSON) -> Doubt.JSON {
switch self {
case let .Leaf(a):
return leaf(a)
return [ "leaf": leaf(a) ]
case let .Indexed(a):
return .Array(a.map(recur))
return [ "indexed": .Array(a.map(recur)) ]
case let .Keyed(d):
return .Dictionary(Dictionary(elements: d.map { ($0, recur($1)) }))
return [ "keyed": .Dictionary(Dictionary(elements: d.map { ($0, recur($1)) })) ]
}
}
}