1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/*
    Appellation: instructions <module>
    Contrib: FL03 <jo3mccain@icloud.com>
    Description:
        Turing machines accept instructions in the form of a five-tuple:
            (State, Symbol, State, Symbol, Move)
*/
pub use self::{head::*, instruction::*, iter::*, moves::*, tail::*};

mod head;
mod instruction;
mod iter;
mod moves;
mod tail;

use crate::{State, Symbolic};
use contained_core::states::Stateful;

pub trait InstructionHead<S: Symbolic>: Stateful<State> {
    fn symbol(&self) -> S;
}

pub trait InstructionTail<S: Symbolic>: Stateful<State> {
    fn action(&self) -> Move;
    fn symbol(&self) -> S;
}

pub trait InstructionSpec<S: Symbolic>: IntoIterator<Item = Self> {
    type Head: InstructionHead<S>;
    type Tail: InstructionTail<S>;

    fn new(head: Self::Head, tail: Self::Tail) -> Self;
    fn head(&self) -> Self::Head;
    fn tail(&self) -> Self::Tail;
}

pub trait InstructionSet<S: Symbolic>: Iterator<Item = Instruction<S>> {
    type Head: InstructionHead<S>;
    type Tail: InstructionTail<S>;

    fn new(head: Self::Head, tail: Self::Tail) -> Self;
    fn cursor(&self) -> usize;
}