[][src]Struct iaith::brainf::Program

pub struct Program {
    pub program: Vec<Token>,
    pub index: usize,
    pub tape: HashMap<i32, u8>,
    pub pointer: i32,
    pub state: State,
    // some fields omitted
}

A container for all the state needed to execute a brainf*ck program.

Fields

program: Vec<Token>

A vector of tokens, representing the executable source code of the program

index: usize

A 'pointer' into the vector of tokens representing where in the code execution is currently happening.

tape: HashMap<i32, u8>

A map of cell number to value, representing the tape the program is manipulating

pointer: i32

A 'pointer' represnting which cell in the tape the program is currently manipulating.

state: State

Represents the state of the program's execution

Implementations

impl Program[src]

pub fn new(source: &str) -> Program[src]

Parse the given source code and construct an new instance of a program ready to be executed. Currently panics if the given source does not represent a valid program.

pub fn step(&mut self) -> Option<String>[src]

Execute the next instruction in the program.

pub fn execute(&mut self) -> String[src]

Execute the program, until it terminates.

Auto Trait Implementations

impl RefUnwindSafe for Program

impl Send for Program

impl Sync for Program

impl Unpin for Program

impl UnwindSafe for Program

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.