earley-omnitool 0.0.6

An Earley parser engine.
Documentation
use cfg::Symbol;

#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Debug)]
pub struct NodeHandle(pub(crate) u32);

pub(super) const NULL_HANDLE: NodeHandle = NodeHandle(0xFFFF_FFFF);

impl NodeHandle {
    #[inline]
    pub(super) fn nulling(symbol: Symbol) -> Self {
        NodeHandle(symbol.usize() as u32)
    }

    #[inline]
    pub(super) fn usize(self) -> usize {
        self.0 as usize
    }

    #[inline]
    pub(super) fn to_option(self) -> Option<NodeHandle> {
        if self == NULL_HANDLE {
            None
        } else {
            Some(self)
        }
    }
}