[][src]Crate sbrain

SBrain, or Semantic Brain, is a set of extensions to the famous language by Urban Müller designed to make it more amenable to genetic programming. Additions include a stack, a general- purpose register, and useful bitwise operations.

This crate provides an implementation of the SBrain specification designed to be used for genetic programming. See the specification pseudomodule for the complete specification.

Here's a quick example:

let program = source_to_tape(",[.,]");
let mut input = make_input_vec(b"Hello, world!");
let mut output = make_output_vec();
SBrainVM::new(Some(&mut input), Some(&mut output), &program)
    .expect("Could not build machine")
    .run(Some(1000)).expect("I/O failed");

let output = output.into_inner();
assert_eq!(&output, b"Hello, world!")

Modules

specification

What is SBrain?

Structs

SBrainVM

A virtual machine modelling the SBrain Turing machine. This machine implements the specification relatively strictly, providing exactly 2^16 (65536) data and instruction cells. Thus, all pointers are 16 bits and all data is 8 bits. The main deviation from the minimum specification is the jump stack, which is indefinitely expandable.

Functions

make_input_vec

Create a new Cursor-wrapped input vector which can be used by a machine to read from.

make_output_vec

Create a new Cursor-wrapped output vector which can be used by a machine to write onto.

simple_run

Converts the given source code to a SBrain executable and runs it, taking input from stdin and doing output on stdout.

source_to_tape

Transliterate a source code into the corresponding instructions.

tape_to_string

Convert a tape of MData cells into Unicode chars. Invalid chars are excluded, which could have some unintended side effects for genesis based on string comparisons.

Type Definitions

MAddr

The type of a pointer to a cell.

MData

The type of a data cell