feat: more scaffolding for machine and tape
This commit is contained in:
1 parent
a52c90d10b
commit
af728ec0bb
2 files changed
+33
-1
No files matched your search
@@ -2,11 +2,31 @@ use std::{collections::HashMap, num::NonZeroU8};
|
||||
|
||||
use crate::tape::{Tape, TapeSymbol};
|
||||
|
||||
const MAX_STATE_COUNT: u8 = 255;
|
||||
|
||||
#[derive(Default)]
|
||||
struct TuringMachine {
|
||||
state_table: HashMap<(MachineState, TapeSymbol), MachineAction>,
|
||||
tape: Tape,
|
||||
}
|
||||
|
||||
impl TuringMachine {
|
||||
fn new() -> Self {
|
||||
Default::default()
|
||||
}
|
||||
|
||||
fn with_state_entries(
|
||||
state_entries: impl Iterator<Item = (MachineState, TapeSymbol, MachineAction)>,
|
||||
) -> Self {
|
||||
let mut machine = TuringMachine::new();
|
||||
for (state, symbol, action) in state_entries {
|
||||
machine.state_table.insert((state, symbol), action);
|
||||
}
|
||||
machine
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Eq, Hash, PartialEq)]
|
||||
enum MachineState {
|
||||
Halt,
|
||||
StateNumber(NonZeroU8),
|
||||
|
||||
Reference in new issue
Block a user