pub(crate) type NonZero<T> = <T as NonZeroT>::Type;
pub trait NonZeroT {
type Type;
}
impl NonZeroT for u64 {
type Type = std::num::NonZeroU64;
}
impl NonZeroT for u32 {
type Type = std::num::NonZeroU32;
}
impl NonZeroT for u16 {
type Type = std::num::NonZeroU16;
}
impl NonZeroT for u8 {
type Type = std::num::NonZeroU8;
}
pub(crate) type PlainToken = u16;
pub(crate) type PlainNode = u16;
pub(crate) type SymbolIdx = u16;
pub(crate) type ProdIdxRaw = u16;
pub(crate) type StateIdxRaw = u32;
pub(crate) struct StateIdx<Kind>(StateIdxRaw, std::marker::PhantomData<*const Kind>);
pub(crate) type ItemIdx = u32;
pub(crate) type GotoIdx = u32;
impl<Kind> Clone for StateIdx<Kind> {
fn clone(&self) -> Self {
*self
}
}
impl<Kind> Copy for StateIdx<Kind> {}
impl<Kind> PartialEq for StateIdx<Kind> {
fn eq(&self, other: &Self) -> bool {
self.0 == other.0
}
}
impl<Kind> Eq for StateIdx<Kind> {}
impl<Kind> std::hash::Hash for StateIdx<Kind> {
fn hash<H: std::hash::Hasher>(&self, state: &mut H) {
self.0.hash(state);
}
}
impl<Kind> std::fmt::Debug for StateIdx<Kind> {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
f.debug_tuple("StateIdx").field(&self.0).finish()
}
}
impl<Kind> From<StateIdx<Kind>> for crate::output::StateIdx {
fn from(s: StateIdx<Kind>) -> Self {
crate::output::StateIdx(s.0)
}
}
impl<Kind> StateIdx<Kind> {
pub(crate) fn new(index: StateIdxRaw) -> Self {
Self(index, std::marker::PhantomData)
}
pub(crate) fn get(self) -> StateIdxRaw {
self.0
}
}