Skip to content

vs-123/mbf

Repository files navigation

MBF

mbf is a modified implementation of the esoteric programming language Brainfuck, with the addition of macros.

mbf is an acronym that stands for "Macro Brainfuck".

HELLO WORLD

# hello_world.mbf
# hello macro
hello {
   > 8+ [< 9+ > -] < .
   > 4+ [< 7+ > -] > +.
   7+ . .
   3+ .
   >> 6+ [< 7+ >-] < ++.
   12- .
   > 6+ [< 9+ >-] < + .
   <.
   3+ .
   6- .
   8- .
   >>> 4+ [< 8+ >-] <+ .
}

# call hello
hello;

USAGE

%  # use `mbf -h` for help

%  mbf ./hello_world.mbf
Hello, World!

%  mbf -E expanded.bf hello_world.mbf
[SUCCESS] file was successfully written!

%  cat expanded.bf
>++++++++[<+++++++++>-]<.>++++[<+++++++>-]<+.+++++++..+++.>>++++++[<+++++++>-]<++.------------.>++++++[<+++++++++>-]<+.<.+++.------.--------.>>>++++[<++++++++>-]<+.

%  # see `examples/` for more examples

FEATURES

  • Macros

  • Strict superset of BF

  • 100% compatible with ordinary BF

  • Includes an interpreter to execute both MBF & BF code

  • Error messages

  • Supports comments

  • Macros can call other macros

  • Infinite cycle detection (see examples/cycle.mbf)

  • Lets you save expanded BF code with -E flag

  • Helpful -h / --help flag for help

BUILD INSTRUCTIONS

  • Clone this repository into mbf/ and cd into it:

    %  git clone --recursive https://github.com/vs-123/mbf.git
    %  ls
    ./  ../  mbf/
    %  cd mbf/

CMake Method

  • Create a build/ directory and cd into it:

    %  mkdir -p build
    %  cd build
    %  ls
    ./  ../
  • Use CMake to generate buildsystem files and then build the project:

    %  cmake ..
    %  cmake --build .
  • You may now use the generated binary

    %  ls
    ./  ../  mbf*  compile_commands.json

Makefile Method

  • Use make to build the project:

    %  pwd
    ~/mbf
    
    %  make build
    [INFO] building...
    [SUCCESS] successfully built!
    
    %  ls build/ && cd $_
    ./ ../ mbf*
    
    %  ./mbf ../examples/hello_world.mbf
    Hello, World!
  • Use make test to run tests: (optional)

    %  make test
    [INFO] building tests...
    [INFO] running tests...
  • To perform a clean operation, use make clean:

    %  make clean
    [INFO] cleaning...
    [SUCCESS] cleaned successfully!

LICENSE

This program is licensed under the GNU Affero General Public License version 3.0 or later.

NO WARRANTY PROVIDED

For full terms, see LICENSE file or visit https://www.gnu.org/licenses/agpl-3.0.html.

About

Macro Brainfuck

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors