https://github.com/wasi0013/bfc
Brainfuck Compiler in Elixir
https://github.com/wasi0013/bfc
brainfuck-compiler elixir
Last synced: 11 months ago
JSON representation
Brainfuck Compiler in Elixir
- Host: GitHub
- URL: https://github.com/wasi0013/bfc
- Owner: wasi0013
- License: mit
- Created: 2020-03-13T14:43:24.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2020-03-28T19:43:03.000Z (about 6 years ago)
- Last Synced: 2025-05-29T23:38:41.436Z (about 1 year ago)
- Topics: brainfuck-compiler, elixir
- Language: Elixir
- Homepage:
- Size: 28.3 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Bfc

[Brainfuck](https://en.wikipedia.org/wiki/Brainfuck) Compiler written in Elixir
# Compile
- Clone this repository.
- Check all the tests are passing by running `mix test`
- Generate an executable by running the command: `mix escript.build`
- The above command should generate an executable named `bfc`
# Run
`./bfc `
**example:**
`./bfc test/fixtures/test_code.bf`
# Try it using REPL
- type `iex -S mix` in the project folder
- Execute a brainfuck code using: `Bfc.Compiler.execute("BF CODE")`
- Compile a brainfuck source code: `Bfc.Compiler.compile("path/to/source.bf")`
**Example:**
```
{_,_, output} = Bfc.Compiler.execute("+++++++++++>+>>>>++++++++++++++++++++++++++++++++++++++++++++>++++++++++++++++++++++++++++++++<<<<<<[>[>>>>>>+>+<<<<<<<-]>>>>>>>[<<<<<<<+>>>>>>>-]<[>++++++++++[-<-[>>+>+<<<-]>>>[<<<+>>>-]+<[>[-]<[-]]>[<<[>>>+<<<-]>>[-]]<<]>>>[>>+>+<<<-]>>>[<<<+>>>-]+<[>[-]<[-]]>[<<+>>[-]]<<<<<<<]>>>>>[++++++++++++++++++++++++++++++++++++++++++++++++.[-]]++++++++++<[->-<]>++++++++++++++++++++++++++++++++++++++++++++++++.[-]<<<<<<<<<<<<[>>>+>+<<<<-]>>>>[<<<<+>>>>-]<-[>>.>.<<<[-]]<<[>>+>+<<<-]>>>[<<<+>>>-]<<[<+>-]>[<+>-]<<<-]")
```
the output should be the [fibonacci](https://en.wikipedia.org/wiki/Fibonacci_number) series
```
"1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89"
```
## Installation as a Package
The package can be installed from github by adding `bfc` to your list of dependencies in `mix.exs`:
```elixir
def deps do
[
{:bfc, git: "https://github.com/wasi0013/bfc.git"}
]
end
```