An optimizing brainfuck interpreter in js
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.
 
 
Juhani Krekelä 06616ff8be Bump version number 3 years ago
.gitignore First commit 5 years ago
.npmignore Prepare for publishing to npm registry 5 years ago
CC0 Switch to CC0 license 3 years ago
README.md Fix typo in the example program 5 years ago
api.md Document the API 5 years ago
architecture.md Document the architecture of Gir 5 years ago
brainfuck.md Support all the types of EOF 5 years ago
gir.html Move Gir to use modules 5 years ago
gir.js Let's not accidentally be quadratic in : 3 years ago
ir.md Document writeInt, readInt, breakPoint 5 years ago
ircbot.js Also replace DEL with its graphical equivalent 5 years ago
optimizations.md Update documentation 5 years ago
package.json Bump version number 3 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?