1
1
mirror of https://github.com/github/semantic.git synced 2024-11-28 10:15:55 +03:00

Implement the eliminators with analysis.

This commit is contained in:
Rob Rix 2015-09-25 12:37:08 -04:00
parent 24bc2610ff
commit 39c46edeb9

View File

@ -12,30 +12,21 @@ public enum Vertex<Element> {
}
public var element: Element? {
switch self {
case let .XY(a, _, _):
return a
case .End:
return nil
}
return analysis(
ifXY: { x, _, _ in x },
ifEnd: const(nil))
}
public var right: Memo<Vertex> {
switch self {
case let .XY(_, xs, _):
return xs
case .End:
return Memo(evaluated: .End)
}
return analysis(
ifXY: { _, xs, _ in xs },
ifEnd: const(Memo(evaluated: .End)))
}
public var down: Memo<Vertex> {
switch self {
case let .XY(_, _, ys):
return ys
case .End:
return Memo(evaluated: .End)
}
return analysis(
ifXY: { _, _, ys in ys },
ifEnd: const(Memo(evaluated: .End)))
}
public var diagonal: Memo<Vertex> {