mod head;
mod movement;
mod state;
mod tail;
pub use head::Head;
pub use movement::Move;
pub use state::State;
pub use tail::Tail;
use std::fmt::{Display, Error, Formatter};
use crate::Symbol;
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct Instruction<S: Symbol> {
pub head: Head<S>,
pub tail: Tail<S>,
}
impl<S: Symbol> Instruction<S> {
pub fn new(head: Head<S>, tail: Tail<S>) -> Self {
Instruction { head, tail }
}
pub fn build(
h_state: State,
h_symbol: S,
t_state: State,
t_symbol: S,
t_movement: Move,
) -> Self {
Instruction::new(
Head::new(h_state, h_symbol),
Tail::new(t_state, t_symbol, t_movement),
)
}
}
impl<S: Symbol> Display for Instruction<S> {
fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error> {
write!(f, "({}) -> ({})", self.head, self.tail)
}
}