https://github.com/hellerve/obf
An optimizing Brainfuck compiler in Pharo
https://github.com/hellerve/obf
Last synced: 12 months ago
JSON representation
An optimizing Brainfuck compiler in Pharo
- Host: GitHub
- URL: https://github.com/hellerve/obf
- Owner: hellerve
- Created: 2023-08-29T14:53:38.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-08-31T09:50:11.000Z (over 2 years ago)
- Last Synced: 2025-02-12T05:11:48.589Z (about 1 year ago)
- Language: Smalltalk
- Size: 10.7 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# obf
An optimizing compiler for Brainfuck in Pharo. Compiles to Pharo VM bytecode.
## Usage
The easiest access to the compiler is done by accessing the (Glamorous Toolkit) views just by getting a live instance:
```
BrainfuckCompiler new
```
You can generate compiled code like this:
```smalltalk
"a regular compile"
BrainfuckCompiler new compile: '++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.>---.+++++++..+++.>>.<-.<.+++.------.--------.>>+.>++.'.
"or enable optimizations"
BrainfuckCompiler new enableOptimizations compile: '++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.>---.+++++++..+++.>>.<-.<.+++.------.--------.>>+.>++.'.
```
The resulting code can be executed using `valueWithReceiver: arguments:`. It doesn’t take any
arguments and the receiver does not matter, so I usually use `self valueWithReceiver: 1 arguments: #()`.
## Installation
```smalltalk
Metacello new
repository: 'github://hellerve/obf:main/src';
baseline: 'Brainfuck';
load
```
Have fun!