macro_rules! program {
{
$(#[default_state($q:expr)])?
rules: {$(($state:expr, $symbol:expr) -> $direction:ident($next:expr, $write:expr));* $(;)?} $(;)?
} => { ... };
}Expand description
The [program!] macro facilitates the creation of new Program
instances using familiar syntax
ⓘ
program! {
#[default_state(initial_state)] // optional
rules: {(state, symbol) -> direction(next_state, write_symbol); ...};
}§Basic Usage
The following example demonstrates the usage of the macro to create a program using three
states {-1, 0, 1} and two symbols {0, 1}.
let rule = rstm::program![
#[default_state(0)] // optional
rules: {
(0, 0) -> Right(1, 1);
(0, 1) -> Left(-1, 0);
(1, 0) -> Right(1, 1);
(1, 1) -> Left(-1, 1);
(-1, 0) -> Right(0, 0);
(-1, 1) -> Left(0, 1);
};