Skip to content
/ bflc Public

A modular compiler framework for Brainfuck-like languages

License

Notifications You must be signed in to change notification settings

bynect/bflc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

The bflc framework

Overview

The BrainFuck-like Languages Compiler (bflc) is a compiler framework that targets Brainfuck and closely related languages.

Build

Before building, get the source code by cloning the repository.

git clone https://github.com/bynect/bflc.git

Build the project using CMake.

cmake -B _build
make -C _build

Note

Guaranteed to work for Linux, requires the Unix Makefile generator for CMake.

Compiler

The compiler is a terminal interface for the blfc library.

Options

  • --debug Set debug output
  • --verbose or -v Set verbose output
  • --help or -h Print help message
  • --version Print version message
  • --frontend=STRING Set one of the available frontends. The default is brainfuck
  • --backend=STRING Set one of the available backends. The default is amd64_asm
  • --front=STRING Alternative name for --frontend option
  • --back=STRING Alternative name for --backend option
  • -o Set output file path. The default is output
  • -fread Use read syscall (not available in all backends)
  • -fwrite Use write syscall (not available in all backends)
  • -fsyscall Equivalent to -fread and -fwrite
  • -fcell=INT Set the number of cells (default is 30000)

Example

# Compile echo.bf to x86_64 nasm assembly
bflc echo.bf -o echo.asm

Note

The amd64 backend is not supported at the moment. To create x86_64 executables assemble the output of amd64_asm.

Library

The framework is by default built as a standalone static library libbflc.a, that can be easily linked with your projects. The frontends and backends are not included in the static library, so you must compile them separately.

Supported frontends

Supported backends

Jit integration

Backends may generate machine code (for example amd64). Since you can use the framework as a library you can create a JIT quite easily. A practical integration example is also available.

Contributing

Contributions are welcome. Please open an issue first for major changes.

Before pushing contributions, please check for errors, memory leaks and other problems with either Asan or Valgrind.

License

The bflc framework is licensed under the terms and conditions of the Apache-2.0 License.