Skip to main content

grammar_utils/lr0/
state.rs

1use super::*;
2
3// TODO contents should be private
4#[derive(Debug)]
5#[derive(Clone, Copy, Eq, PartialEq, Hash, Ord, PartialOrd)]
6pub struct StateIndex(pub usize);
7
8#[derive(PartialEq, Eq)]
9pub struct State<'g> {
10    itemset: ItemSet<'g>,
11}
12
13impl<'g> State<'g> {
14    pub(crate) fn new(itemset: ItemSet<'g>) -> Self {
15        State {
16            itemset,
17        }
18    }
19
20    pub fn itemset(&self) -> &ItemSet<'g> {
21        &self.itemset
22    }
23}
24
25impl From<StateIndex> for usize {
26    fn from(value: StateIndex) -> Self {
27        value.0
28    }
29}