Giter VIP home page Giter VIP logo

brainfuck-rs's Introduction

Brainfuck-exe

a simple brainfuck interpreter crate implemented in rust ๐Ÿฆ€ with many available customizations for flexibility
For more information visit the documentation here

Usage

In your Cargo.toml:

brainfuck-exe = "*"

If you are only using it as a library, and the CLI is not needed,
disable the cli (included by default) feature to remove unecessary dependencies:

brainfuck-exe = { version = "*", default-features = false }

Example

Below is a basic example on how to use the crate

use std::fs::File;
// import Result typealias and interpreter struct
use brainfuck_exe::{Result, Brainfuck};

fn main() -> Result<()> {
    // brainfuck code to print "Hello, World!"
    let code = ">++++++++[<+++++++++>-]<.>++++[<+++++++>-]<+.+++++++..+++.>>++++++[<+++++++>-]<+
    +.------------.>++++++[<+++++++++>-]<+.<.+++.------.--------.>>>++++[<++++++++>-]<+.";
    // instantiate a new interpreter instance with the code
    Brainfuck::new(code)
        // optional builder method to write the output into a file not STDOUT
        .with_output(
            File::options()
                .write(true)
                .open("tests/output.txt")
                .unwrap()
        )
        // executes the code
        .execute()?;

    // alternatively use this to retrieve the code from an existing source file
    Brainfuck::from_file("tests/hello_world.bf")?
        .execute()?;

    Ok(())
}

CLI

You can also use this crate as a CLI program

# installation
$ cargo install brainfuck-exe
# usage
$ brainfuck --help
$ brainfuck [CODE] [-f FILE] [OPTIONS]

brainfuck-rs's People

Contributors

dependabot[bot] avatar tom-the-bomb avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.