1
2pub use visita_macros::{node_group, visitor};
3
4pub trait NodeFamily<V> : Sized where V : Visitor<Self> {
6 type Data;
7
8 fn accept(&self, v: &mut V) -> V::Output;
9}
10
11pub trait Node<V> : Sized where V : Visitor<Self::Family> + Visit<Self> {
13 type Family : NodeFamily<V>;
14
15 fn accept(&self, v: &mut V, data: &Data<V, Self>) -> V::Output {
16 v.visit(self, data)
17 }
18}
19
20pub trait Visitor<F> : Sized where F : NodeFamily<Self> {
22 type Output;
23}
24
25pub trait Visit<N> : Visitor<N::Family> where N : Node<Self> {
27 fn visit(&mut self, node: &N, data: &Data<Self, N>) -> Self::Output;
28}
29
30pub type Data<V, N> = <<N as Node<V>>::Family as NodeFamily<V>>::Data;