You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
4 years ago | |
---|---|---|
.gitignore | 6 years ago | |
.npmignore | 6 years ago | |
CC0 | 4 years ago | |
README.md | 6 years ago | |
api.md | 6 years ago | |
architecture.md | 6 years ago | |
brainfuck.md | 6 years ago | |
gir.html | 6 years ago | |
gir.js | 4 years ago | |
ir.md | 6 years ago | |
ircbot.js | 6 years ago | |
optimizations.md | 6 years ago | |
package.json | 4 years ago |
README.md
Gir is an optimizing brainfuck interpreter in Javascript.
Name
𒌋𒀜 gir (Sumerian) - n. kiln
License
Everything in the repo is under Unlicense / CC0.
Status
Gir can parse, prettyprint, and run programs in brainfuck. Gir supports following optimizations:
- Turn runs of +- or <> into one command
- Turn [-] or [+] into one command
- Add offsets to commands that modify tape, to reduce moving tape head
- Turn multiply loops into one command
Examples
ircbot.js
is an implementation of an IRC bot's brainfuck interpreter
function. Smaller examples for every function are available in api.md
const gir = require('bf-gir');
let compiled = gir.compile(',[+.,]');
let input = gir.encodeUTF8('Foobar');
let vm = gir.newVM(compiled, input);
let result = gir.runVM(vm, 1000);
if(result.complete) {
console.log(gir.decodeUTF8(result.state.output));
} else {
console.log('Bf program terminated abnormally');
}
Installing
Gir is available at npm registry under the name bf-gir.
TODO
gir.html
- Implement a UI
General
- Move stuff into subdirectories?