Skip to content

Commit

Permalink
Clean up and implement Debug for State
Browse files Browse the repository at this point in the history
  • Loading branch information
Cypher1 committed Sep 22, 2024
1 parent 8f35809 commit f0b5657
Show file tree
Hide file tree
Showing 2 changed files with 219 additions and 123 deletions.
10 changes: 6 additions & 4 deletions partable-parser/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,19 @@ pub enum Direction {
C = 0b101, // Close (i.e. return first child)
}

pub trait Symbol<const SIZE: usize>: Copy + Clone + std::hash::Hash + PartialEq + PartialOrd + Eq + Ord {
pub trait Symbol<const SIZE: usize>:
Copy + Clone + std::hash::Hash + PartialEq + PartialOrd + Eq + Ord
{
const SIZE: usize = SIZE;

const TABLE: DirTable< SIZE >;
const TABLE: DirTable<SIZE>;
}

pub struct DirTable<const N: usize> {
table: [[Direction; N]; N]
table: [[Direction; N]; N],
}

impl <const N: usize> DirTable<N> {
impl<const N: usize> DirTable<N> {
pub fn dir<S: Symbol<N> + Into<usize>>(&self, left: S, right: S) -> Direction {
self.table[left.into()][right.into()]
}
Expand Down
Loading

0 comments on commit f0b5657

Please sign in to comment.