use ena::unify::{UnifyKey, UnifyValue};
use crate::lr1::lane_table::table::context_set::{ContextSet, OverlappingLookahead};
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
pub struct StateSet {
index: u32,
}
impl UnifyKey for StateSet {
type Value = ContextSet;
fn index(&self) -> u32 {
self.index
}
fn from_index(u: u32) -> Self {
StateSet { index: u }
}
fn tag() -> &'static str {
"StateSet"
}
}
impl UnifyValue for ContextSet {
type Error = (Self, Self);
fn unify_values(value1: &Self, value2: &Self) -> Result<Self, (Self, Self)> {
match ContextSet::union(value1, value2) {
Ok(v) => Ok(v),
Err(OverlappingLookahead) => Err((value1.clone(), value2.clone())),
}
}
}