All Projects → brain-lang → Brain

brain-lang / Brain

Licence: mit
A high level programming language that compiles into the brainfuck esoteric programming language

Programming Languages

rust
11053 projects
language
365 projects

Labels

Projects that are alternatives of or similar to Brain

MIRACL
Multi-modal Image Registration And Connectivity anaLysis
Stars: ✭ 23 (-78.7%)
Mutual labels:  brain
kaggle brain-tumor-3D
Predict the status of a genetic biomarker important for brain cancer treatment
Stars: ✭ 20 (-81.48%)
Mutual labels:  brain
Fieldtrip
The MATLAB toolbox for MEG, EEG and iEEG analysis
Stars: ✭ 481 (+345.37%)
Mutual labels:  brain
threeBrain
3D Visualization of Brain MRI
Stars: ✭ 29 (-73.15%)
Mutual labels:  brain
HumanPilot
Spatial Transcriptomics human DLPFC pilot study part of the spatialLIBD project
Stars: ✭ 22 (-79.63%)
Mutual labels:  brain
BrainPrep
Preprocessing pipeline on Brain MR Images through FSL and ANTs, including registration, skull-stripping, bias field correction, enhancement and segmentation.
Stars: ✭ 107 (-0.93%)
Mutual labels:  brain
prime-re.github.io
Open resource exchange platform for non-human primate neuroimaging
Stars: ✭ 13 (-87.96%)
Mutual labels:  brain
Brains
'Expanding Brain' Meme Generator
Stars: ✭ 66 (-38.89%)
Mutual labels:  brain
syncopy
Systems Neuroscience Computing in Python: user-friendly analysis of large-scale electrophysiology data
Stars: ✭ 19 (-82.41%)
Mutual labels:  brain
Wechat brain
知乎答题王(头脑王者)辅助工具
Stars: ✭ 436 (+303.7%)
Mutual labels:  brain
brainfuck
Brainfuck interpreter companion to the brain programming language
Stars: ✭ 32 (-70.37%)
Mutual labels:  brain
neuralBlack
A Multi-Class Brain Tumor Classifier using Convolutional Neural Network with 99% Accuracy achieved by applying the method of Transfer Learning using Python and Pytorch Deep Learning Framework
Stars: ✭ 36 (-66.67%)
Mutual labels:  brain
pybraincompare
brain image comparison and visualization methods for python!
Stars: ✭ 16 (-85.19%)
Mutual labels:  brain
DeepHyperNEAT
A public python implementation of the DeepHyperNEAT system for evolving neural networks. Developed by Felix Sosa and Kenneth Stanley. See paper here: https://eplex.cs.ucf.edu/papers/sosa_ugrad_report18.pdf
Stars: ✭ 42 (-61.11%)
Mutual labels:  brain
Neurokernel
Neurokernel Project
Stars: ✭ 491 (+354.63%)
Mutual labels:  brain
ANTsR
Advanced Normalization Tools in R
Stars: ✭ 101 (-6.48%)
Mutual labels:  brain
AD Prediction
Alzheimer's Disease Prediction by using ResNet, AlexNet
Stars: ✭ 118 (+9.26%)
Mutual labels:  brain
3d Gan Superresolution
3D super-resolution using Generative Adversarial Networks
Stars: ✭ 97 (-10.19%)
Mutual labels:  brain
Awesome Neuroscience
A curated list of awesome neuroscience libraries, software and any content related to the domain.
Stars: ✭ 734 (+579.63%)
Mutual labels:  brain
P Brain.ai
Natural language virtual assistant using Node.js + Bootstrap
Stars: ✭ 307 (+184.26%)
Mutual labels:  brain

brain

Crates.io Crates.io Build Status Build status Dependency Status Gitter

brain is a strongly-typed, high-level programming language that compiles into brainfuck. Its syntax is based on the Rust programming language (which it is also implemented in). Though many Rust concepts will work in brain, it deviates when necessary in order to better suit the needs of brainfuck programming.

brainfuck is an esoteric programming language with only 8 single-byte instructions: +, -, >, <, ,, ., [, ]. These limited instructions make brainfuck code extremely verbose and difficult to write. It can take a long time to figure out what a brainfuck program is trying to do. brain makes it easier to create brainfuck programs by allowing you to write in a more readable and understandable language.

The type system makes it possible to detect a variety of logical errors when compiling, instead of waiting until runtime. This is an extra layer of convenience that brainfuck does not have. The compiler takes care of generating all the necessary brainfuck code to work with the raw bytes in the brainfuck turing machine.

The brain programming language compiles directly into brainfuck. The generated brainfuck code can be run by a brainfuck interpreter. brain only targets this interpreter which means that its generated programs are only guaranteed to work when run with that. The interpreter implements a brainfuck specification specially designed and written for the brain programming language project.

Optimization Goals

The brain compiler is designed to optimize the generated brainfuck code as much as possible.

  1. Generate small brainfuck files (use as few instructions as possible)
  2. Generate memory efficient code (use as few brainfuck cells as possible)

Optimization is an ongoing effort. As the project matures, these goals will become more expressed in the compiled output of the program.

brain syntax

For full examples, please see the examples/ directory. Some examples aren't fully implemented yet in the compiler.

cat program (examples/cat.brn)

// cat program
let mut ch: [u8; 1];

while true {
  // stdin.read_exact() panics if EOF is reached
  stdin.read_exact(ch);
  stdout.print(ch);
}

Compile this with brain examples/cat.brn.

Run this with brainfuck cat.bf < someinputfile.txt.

Reading Input (examples/input.brn)

// input requires explicit sizing
// always reads exactly this many characters or panics if EOF is reached before then
// if this many characters aren't available yet, it waits for you to send that many
let mut b: [u8; 5];
stdin.read_exact(b);
stdout.print(b"b = ", b, b"\n");

let mut c: [u8; 1];
stdin.read_exact(c);
stdout.print(b"c = ", c, b"\n");

// You can reuse allocated space again
stdin.read_exact(b);
stdout.print(b"b = ", b, b"\n");

Compile this with brain examples/input.brn.

This compiles into the following brainfuck:

,>,>,>,>,>+++++++++++++++++++++++++++++++++
+++++++++++++++++++++++++++++++++++++++++++
++++++++++++++++++++++.--------------------
-------------------------------------------
---.+++++++++++++++++++++++++++++.---------
--------------------.----------------------
----------<<<<<.>.>.>.>.>++++++++++.-------
---,>++++++++++++++++++++++++++++++++++++++
+++++++++++++++++++++++++++++++++++++++++++
++++++++++++++++++.------------------------
-------------------------------------------
.+++++++++++++++++++++++++++++.------------
-----------------.-------------------------
-------<.>++++++++++.----------<<<<<<,>,>,>
,>,>>++++++++++++++++++++++++++++++++++++++
+++++++++++++++++++++++++++++++++++++++++++
+++++++++++++++++.-------------------------
-----------------------------------------.+
++++++++++++++++++++++++++++.--------------
---------------.---------------------------
-----<<<<<<.>.>.>.>.>>++++++++++.----------

Run this after compiling with brainfuck input.bf < someinputfile.txt.

Installation

For people just looking to use brain, the easiest way to get brain right now is to first install the Cargo package manager for the Rust programming language.

NOTE: Until this version is released, these instructions will NOT work. Please see the Usage instructions below for how to manually install the compiler from the source code.

Then in your terminal run:

cargo install brain
cargo install brain-brainfuck

If you are upgrading from a previous version, run:

cargo install brain --force
cargo install brain-brainfuck --force

Usage

For anyone just looking to compile with the compiler:

  1. Follow the installation instructions above
  2. Run brain yourfile.brn to compile your brain code
  3. Run brainfuck yourfile.bf to run a brainfuck interpreter which will run your generated brainfuck code

You can also specify an output filename. Run brain --help for more information.

For anyone looking to build the source code:

This project contains both the brain compiler and a basic brainfuck interpreter.

Make sure you have Rust and cargo (comes with Rust) installed.

brain compiler

To compile a brain (.brn) file into brainfuck (.bf)

cargo run filename.brn

where filename.brn is the brain program you want to compile

Use --help to see further options and additional information

cargo run -- --help

If the brain compiler seems to be taking too long or "hanging", try running cargo build first to see if the Rust compiler is just taking too long for some reason.

You can also install the compiler from the source code using this command in the repository's root directory:

cargo install --path .

Examples

There are various brain examples in the examples/ directory which you can compile into brainfuck using the usage instructions above.

Thanks

This project would not be possible without the brilliant work of the many authors of the Esolang Brainfuck Algorithms page. The entire wiki has been invaluable. That page in particular is the basis for a lot of the code generation in this compiler. I have contributed many novel brainfuck algorithms to that page as I come up with them for use in this compiler.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].