1
1
mirror of https://github.com/github/semantic.git synced 2024-12-12 14:45:40 +03:00
semantic/prototype/Doubt/Info.swift

27 lines
549 B
Swift
Raw Normal View History

2015-10-01 21:25:17 +03:00
/// Source info & categorization for nodes in a syntax tree.
2015-10-01 16:46:02 +03:00
public enum Info: AlgebraicHashable {
2015-09-30 23:01:47 +03:00
case Literal(String, Set<Category>)
public var categories: Set<Category> {
switch self {
case let .Literal(_, c):
return c
}
}
2015-10-01 16:46:02 +03:00
public var hash: Hash {
switch self {
case let .Literal(source, categories):
return Hash("Literal", Hash(source), Hash(categories))
}
}
2015-09-30 22:58:01 +03:00
}
public func == (left: Info, right: Info) -> Bool {
switch (left, right) {
case let (.Literal(s1, c1), .Literal(s2, c2)):
return s1 == s2 && c1 == c2
}
}