Brainfu*k interpreter and REPL written in RustπŸ¦€

Overview

brainfuc*k interpreter

brainfuck interpreter: a simple brainfuck interpreter and REPL writen in rust πŸ¦€

Read this in other languages.

AR Arabic-Ψ§Ω„ΨΉΨ±Ψ¨ΩŠΨ©

Features

  • Run brainfuc*k code from a file πŸ’«
  • Run brainfuc*k live code from the REPL πŸš€
  • Support utf-8 characters including emojis 😍 (optional)
  • You can control in the array size πŸ“

Install

  • from crates.io
    cargo install bfy
  • From aur:
    yay -S bfy

Options and arguments

Options table
Option Description Default
-h, --help Prints help information
-V, --version Prints version information
-f, --features The extra features to enable
Possible values:
  • no-reverse-value:
    If the value is you want decrement the value and the value is 0, don't set the value to 255, otherwise decrement the value.
    If the value is you want increment the value and the value is 255, don't set the value to 0, otherwise increment the value. The alias are: `nrv`
  • reverse-pointer:
    If the pointer at the end of the array, set the pointer to 0, otherwise increment the pointer.
    If the pointer at the beginning of the array, set the pointer to the end of the array, otherwise decrement the pointer. The alias are: `rp`
  • allow-utf8:
    Allow the use of utf8 characters (32 bit), otherwise only 8 bit characters are allowed.
    Use this feature with caution because it increases the cell size from 8 bits to 32 bits.
    It also allow you to use the emoji in your brainfuck code :D, This is if you can preserve your mind so that you can access their digital value :).
    The `u32` in rust can only store values from 0 to 4294967295, but we can only use 0 to 1114111 (0x10FFFF) for now. The alias are: `utf8`
n/a
-a, --array-size The size of the array 30000
-w, --without-tiles Dont print the tiles (e.g. exit code, file name, etc)
Help option output
bfy --help
Brainfu*k interpreter and REPL written in Rust

Usage: bfy [OPTIONS] [SOURCE]

Arguments:
  [SOURCE]
          The brainfuck source code file to run (if not will be entered in REPL mode)

Options:
  -f, --features <FEATURES>
          Possible values:
          - no-reverse-value:
            If the value is you want decrement the value and the value is 0, don't set the value to 255, otherwise decrement the value. If the
            value is you want increment the value and the value is 255, don't set the value to 0, otherwise increment the value. The alias are:
            `nrv`
          - reverse-pointer:
            If the pointer at the end of the array, set the pointer to 0, otherwise increment the pointer. If the pointer at the beginning of the
            array, set the pointer to the end of the array, otherwise decrement the pointer. The alias are: `rp`
          - allow-utf8:
            Allow the use of utf8 characters (32 bit), otherwise only 8 bit characters are allowed. Use this feature with caution because it
            increases the cell size from 8 bits to 32 bits. It also allow you to use the emoji in your brainfuck code :D, This is if you can
            preserve your mind so that you can access their digital value :). The `u32` in rust can only store values from 0 to 4294967295, but we
            can only use 0 to 1114111 (0x10FFFF) for now. The alias are: `utf8`

  -a, --array-size <ARRAY_SIZE>
          The brainfuck array size
          
          [default: 30000]

  -w, --without-tiles
          Dont print the tiles (e.g. exit code, file name, etc)

  -h, --help
          Print help information (use `-h` for a summary)

  -V, --version
          Print version information

Examples

bfy test_code/hello_world.bf
Hello world!
Successfully ran brainfuck source code from file: test_code/hello_world.bf
Exiting with code: 0
bfy -w test_code/hello_world.bf
Hello world!
bfy test_code/print_hi_yooo.bf
Hi yoooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo!Successfully ran brainfuck source code from file: test_code/print_hi_yooo.bf
Exiting with code: 0
bfy -w test_code/print_hi_yooo.bf
Hi yoooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo!
bfy test_code/like_cat.bf

output

Note: The output is not the same as the current version of the interpreter, but it is the same as the output of the interpreter when I wrote the code.

REPL

bfy # REPL mode

print @ and A in the repl

TODO

  • Add more tests
  • Add more examples
  • Create the brainfuck formatter
  • Add syntax highlighting in the REPL
  • Add auto completion in the REPL
  • Support dynamic array size feature

Resources

Comments
  • Configure Renovate

    Configure Renovate

    Mend Renovate

    Welcome to Renovate! This is an onboarding PR to help you understand and configure settings before regular Pull Requests begin.

    🚦 To activate Renovate, merge this Pull Request. To disable Renovate, simply close this Pull Request unmerged.


    Detected Package Files

    • Cargo.toml (cargo)
    • .github/workflows/test.yml (github-actions)

    Configuration Summary

    Based on the default config's presets, Renovate will:

    • Start dependency updates only once this onboarding PR is merged
    • Enable Renovate Dependency Dashboard creation.
    • If Renovate detects semantic commits, it will use semantic commit type fix for dependencies and chore for all others.
    • Ignore node_modules, bower_components, vendor and various test/tests directories.
    • Automatically detect the best rangeStrategy to use.
    • Rate limit PR creation to a maximum of two per hour.
    • Limit to maximum 10 open PRs at any time.
    • Group known monorepo packages together.
    • Use curated list of recommended non-monorepo package groupings.
    • A collection of workarounds for known problems with packages.

    πŸ”‘ Would you like to change the way Renovate is upgrading your dependencies? Simply edit the renovate.json in this branch with your custom config and the list of Pull Requests in the "What to Expect" section below will be updated the next time Renovate runs.


    What to Expect

    With your current configuration, Renovate will create 3 Pull Requests:

    fix(deps): update rust crate console to 0.15.5
    • Schedule: ["at any time"]
    • Branch name: renovate/console-0.x
    • Merge into: master
    • Upgrade console to 0.15.5
    fix(deps): update rust crate clap to 4.1.4
    • Schedule: ["at any time"]
    • Branch name: renovate/clap-4.x
    • Merge into: master
    • Upgrade clap to 4.1.4
    chore(deps): update actions/checkout action to v3
    • Schedule: ["at any time"]
    • Branch name: renovate/actions-checkout-3.x
    • Merge into: master
    • Upgrade actions/checkout to v3

    🚸 Branch creation will be limited to maximum 2 per hour, so it doesn't swamp any CI resources or overwhelm the project. See docs for prhourlylimit for details.


    ❓ Got questions? Check out Renovate's Docs, particularly the Getting Started section. If you need any further assistance then you can also request help here.


    This PR has been generated by Mend Renovate. View repository job log here.

    size/XS 
    opened by renovate[bot] 0
  • [ImgBot] Optimize images

    [ImgBot] Optimize images

    Beep boop. Your images are optimized!

    Your image file size has been reduced by 15% πŸŽ‰

    Details

    | File | Before | After | Percent reduction | |:--|:--|:--|:--| | /screenshots/like_cat_output.png | 16.48kb | 12.47kb | 24.33% | | /screenshots/repl_print_at_and_A_0.1.0.png | 115.50kb | 92.08kb | 20.28% | | /assets/cover.png | 87.09kb | 78.59kb | 9.77% | | /assets/cover.jpg | 40.42kb | 38.06kb | 5.85% | | | | | | | Total : | 259.50kb | 221.20kb | 14.76% |


    πŸ“ docs | :octocat: repo | πŸ™‹πŸΎ issues | πŸͺ marketplace

    ~Imgbot - Part of Optimole family

    opened by imgbot[bot] 0
  • chore(deps): update actions/checkout action to v3

    chore(deps): update actions/checkout action to v3

    Mend Renovate

    This PR contains the following updates:

    | Package | Type | Update | Change | |---|---|---|---| | actions/checkout | action | major | v2 -> v3 |


    Release Notes

    actions/checkout

    v3

    Compare Source


    Configuration

    πŸ“… Schedule: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

    🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.

    β™» Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

    πŸ”• Ignore: Close this PR and you won't be reminded about this update again.


    • [ ] If you want to rebase/retry this PR, check this box

    This PR has been generated by Mend Renovate. View repository job log here.

    size/XS 
    opened by renovate[bot] 0
  • Dependency Dashboard

    Dependency Dashboard

    This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

    Open

    These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

    Detected dependencies

    cargo
    Cargo.toml
    • clap 4.0.14
    • log 0.4.17
    • pretty_env_logger 0.4.0
    • colored 2.0.0
    • console 0.15.2
    • pretty_assertions 1.3.0
    github-actions
    .github/workflows/test.yml
    • actions/checkout v2

    • [ ] Check this box to trigger a request for Renovate to run again on this repository
    opened by renovate[bot] 0
  • fix(deps): update rust crate clap to 4.1.4

    fix(deps): update rust crate clap to 4.1.4

    Mend Renovate

    This PR contains the following updates:

    | Package | Type | Update | Change | |---|---|---|---| | clap | dependencies | minor | 4.0.14 -> 4.1.4 |


    Release Notes

    clap-rs/clap

    v4.1.4

    Compare Source

    Fixes
    • (help) Respect disable_colored_help when using arg_required_else_help
    Performance
    • Speed up compiling arg! macro

    v4.1.3

    Compare Source

    Fixes
    • (error) Improve suggested flag/value/subcommand when two share a long preifx
    • (error) When suggesting one of several subcommands, use the plural subcommands, rather than subcommand

    v4.1.2

    Compare Source

    Fixes
    • In documentation, refer to get_flag, rather than get_one::<bool>

    v4.1.1

    Compare Source

    Fixes
    • (error) Small softening attempt for "unexpected argument" error

    v4.1.0

    Compare Source

    Compatibility

    MSRV changed to 1.64.0

    For apps with custom --help and --version flags:

    • Descriptions for --help and --version changed

    When apps have errors imitating clap's error style:

    • Error message style was changed, including
      • Moving away from "did you mean" to tips
      • Leading letter is lower case
      • "For more" added some punctuation
    Features
    • ArgMatches::get_occurrences support for argument values to be grouped by their occurrence
    Fixes
    • (derive) Allow upgrade_from when arguments / subcommands are explicitly marked as required
    • (help) Try be more clearer and succinct with --help and --version (also helps with overflow)
    • (error) Try to be more clearer and succinct with error messages
    • (error) Officially adopt an error style guide

    v4.0.32

    Compare Source

    Fixes
    • (parser) When overriding required(true), consider args that conflict with its group

    v4.0.31

    Compare Source

    Performance
    • Speed up parsing when a lot of different flags are present (100 unique flags)

    v4.0.30

    Compare Source

    Fixes
    • (error) Improve error for args_conflicts_with_subcommand

    v4.0.29

    Compare Source

    v4.0.28

    Compare Source

    Fixes
    • Fix wasm support which was broken in 4.0.27

    v4.0.27

    Compare Source

    Features
    • Have Arg::value_parser accept Vec<impl Into<PossibleValue>>
    • Implement Display and FromStr for ColorChoice
    Fixes
    • Remove soundness issue by switching from atty to is-terminal

    v4.0.26

    Compare Source

    Fixes
    • (error) Fix typos in ContextKind::as_str

    v4.0.25

    Compare Source

    Features
    • (error) Report available subcommands when required subcommand is missing

    v4.0.24

    Compare Source

    Fixes
    • Avoid panic when printing an argument that isn't built

    v4.0.23

    Compare Source

    Fixes
    • Don't panic on reporting invalid-long errors when followed by invalid UTF8
    • (help) Clarified argument to help subcommand

    v4.0.22

    Compare Source

    Fixes
    • (help) Don't overflow into next-line-help early due to stale (pre-v4) padding calculations

    v4.0.21

    Compare Source

    Features
    • (derive) long_about and long_help attributes, without a value, force using doc comment (before it wouldn't be set if there wasn't anything different than the short help)

    v4.0.20

    Compare Source

    Fixes
    • (derive) Allow defaulted value parser for '()' fields

    v4.0.19

    Compare Source

    Features
    • ColorChoice now implements ValueEnum

    v4.0.18

    Compare Source

    Fixes
    • (derive) Allow #[command(skip)] to also work with enum variants with a value

    v4.0.17

    Compare Source

    Fixes
    • Allow using Arg::last(true) with Arg::value_hint(ValueHint::CommandWithArguments)

    v4.0.16

    Compare Source

    Fixes
    • Arg::exclusive(true) should not be exclusive with the argument's own ArgGroup

    v4.0.15

    Compare Source

    Fixes
    • (error) Don't suggest -- when it doesn't help
    • (error) Be more consistent in quoting, punctuation, and indentation in errors

    Configuration

    πŸ“… Schedule: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

    🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.

    β™» Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

    πŸ”• Ignore: Close this PR and you won't be reminded about this update again.


    • [ ] If you want to rebase/retry this PR, check this box

    This PR has been generated by Mend Renovate. View repository job log here.

    size/XS 
    opened by renovate[bot] 0
  • fix(deps): update rust crate console to 0.15.5

    fix(deps): update rust crate console to 0.15.5

    Mend Renovate

    This PR contains the following updates:

    | Package | Type | Update | Change | |---|---|---|---| | console | dependencies | patch | 0.15.2 -> 0.15.5 |


    Release Notes

    console-rs/console

    v0.15.5

    Compare Source

    Enhancements
    • Removed regex dependency. (#​153)
    • Clarified that clicolors-control is no longer used.
    • Handle non-tty terminals in read_char. (#​124)

    v0.15.4

    Compare Source

    Enhancements
    • Fix for regression where console size was misreported on windows. (#​151)

    v0.15.3

    Compare Source

    Enhancements
    • Dropped terminal_size dependency.

    Configuration

    πŸ“… Schedule: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

    🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.

    β™» Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

    πŸ”• Ignore: Close this PR and you won't be reminded about this update again.


    • [ ] If you want to rebase/retry this PR, check this box

    This PR has been generated by Mend Renovate. View repository job log here.

    size/XS 
    opened by renovate[bot] 0
Releases(0.1.1)
Owner
Anas Elgarhy
he/him, 19, Software Engineer. PC hardware enthusiast and tinkerer. Silly boy doing silly things in a silly world.
Anas Elgarhy
Regorus - Rego interpreter, analyzer and validator written in Rust

regorus THIS REPOSITORY IS IN ACTIVE DEVELOPMENT AND NOT INTENDED FOR PRODUCTION USE. Regorus is a Rego interpreter, analyzer and checker written in R

Microsoft 13 Mar 2, 2023
Brainfuck interpreter written in rust

Brainfuck Interpreter Written in Rust Simple Interpreter that runs bare Brainfuck and extends it with debug command # which prints content of first te

Was 1 Nov 28, 2021
The brainfuck language interpreter written in Rust

The brainfuck language interpreter written in Rust

Jan Ε taffa 1 Feb 21, 2022
A Brainf** interpreter written in rust πŸ¦€

Brainf Interpreter An interpreter for the esoteric programming language Brainfuck written in rust ?? Compilation NOTE: To compile the project, you nee

Chitram Dasgupta 2 Sep 12, 2022
Brainf - A brainfuck interpreter written in Rust πŸ¦€

brainf A brainfuck interpreter written in Rust ?? . Do not I wrote this in my spare time... but still its good! Run Locally Clone the project git cl

Nav 3 Oct 8, 2022
A simple interpreter written in Rust programming language.

Interpreter in Rust A simple interpreter written in Rust programming language. Getting Started These instructions will get you a copy of the project u

Ismail Mosleh 5 Feb 17, 2023
Compiler & Interpreter for the (rather new and very experimental) Y programming language.

Y Lang Why would anyone build a new (and rather experimental) language with no real world use case. Design Y (pronounced as why) is based on the idea

Louis Meyer 8 Mar 5, 2023
rlox-interpreter is an AST-walking implementation of Bob Nystrom's Lox language in Rust.

rlox-interpreter rlox-interpreter is an AST-walking implementation of Bob Nystrom's Lox language in Rust. Disclaimer: This is my first Rust project, d

Paul Fedorow 3 Oct 5, 2022
Risc-V assembly interpreter built with pure Rust

Risc-V Interpreter Interpreter for Risc-V assembly built with Rust Report bug Β· Request feature Table of contents Quick start Exemple Program Instruct

null 2 Aug 24, 2022
This crate defines a single macro that is a brainfunct compile-time interpreter.

Compile Protection This crate defines a single macro that is a brainfunct compile-time interpreter. One example is as follows #![recursion_limit = "18

John Marsden 7 Nov 29, 2021
PICNIC Is Config Notation Interpreter/Converter

PICNIC Is Config Notation Interpreter/Converter ?? PICNIC PICNIC's name is powered by AI, which immediately makes it worth your time: Human: Please co

Fabricio DemattΓͺ 4 Jul 13, 2023
This is a Discord bot written in Rust to translate to and from the Bottom Encoding Standard using bottom-rs and Serenity.

bottom-bot This is a Discord bot written in Rust to translate to and from the Bottom Encoding Standard using bottom-rs and Serenity. Ever had this pro

Bottom Software Foundation 11 Dec 10, 2022
Opensource diagnostic software for Daimler vehicles, inspired by Xentry and DAS, written in Rust

OPENSTAR An opensource diagnostic application for Daimler vehicles inspired by DAS and Xentry. Some of the work here is based on OpenVehicleDiag If yo

Ashcon Mohseninia 21 Nov 20, 2022
A little bit fast and modern Ruby version manager written in Rust

A little bit fast and modern Ruby version manager written in Rust Features Pure Rust implementation not using ruby-build Cross-platform support (macOS

Takayuki Maeda 510 Jan 5, 2023
DWARF packaging utility, written in Rust, supporting GNU extension and DWARF 5 package formats.

thorin thorin is an DWARF packaging utility for creating DWARF packages (*.dwp files) out of input DWARF objects (*.dwo files; or *.o files with .dwo

David Wood 19 Nov 16, 2022
Fast and simple PHP version manager written in rust

[WIP] phpup (PHP-up): Fast and Simple PHP version manager ⚑ Fast and simple PHP version manager, written in rust Features No requirements for system P

null 27 Dec 25, 2022
A shiny new package manager written in rust explicitly for gemlock/linux and it's distributions

Gem A shiny new package manager written in rust explicitly for gemlock/linux and it's distributions. List of content How to setup Systems Ubuntu Arch

Gemlock 1 Feb 22, 2022
An example Kibana plugin written in Rust and Typescript

An example Kibana plugin written in Rust and Typescript

Aleh Zasypkin 3 Dec 24, 2022
A highly modular Bitcoin Lightning library written in Rust. Its Rust-Lightning, not Rusty's Lightning!

Rust-Lightning is a Bitcoin Lightning library written in Rust. The main crate, lightning, does not handle networking, persistence, or any other I/O. Thus, it is runtime-agnostic, but users must implement basic networking logic, chain interactions, and disk storage. More information is available in the About section.

Lightning Dev Kit 850 Jan 3, 2023