1
1
mirror of https://github.com/github/semantic.git synced 2024-12-24 23:42:31 +03:00

Use the category method.

This commit is contained in:
Rob Rix 2015-10-28 17:24:41 -04:00
parent 90caa11870
commit b13d3f7d59

View File

@ -81,20 +81,16 @@ func termWithInput(string: String) -> Term? {
switch category {
case .Pair:
return try .Fixed(node.namedChildren.map {
guard let category = Info.Category(rawValue: try node.name(document)) else { throw E() }
return ($0, category)
($0, try node.category(document))
})
case .Object:
return try .Keyed(Dictionary(elements: node.namedChildren.map {
let name = try node.name(document)
guard let category = Info.Category(rawValue: name) else { throw E() }
// fixme: this should return the key in the pair.
return (name, ($0, category))
try (node.name(document), ($0, node.category(document)))
}))
default:
return try .Indexed(node.namedChildren.map {
guard let category = Info.Category(rawValue: try node.name(document)) else { throw E() }
return ($0, category)
($0, try node.category(document))
})
}
} (root, Info.Category.Program)