An optimizing brainfuck interpreter in js
Go to file
Juhani Krekelä 06616ff8be Bump version number 2019-09-14 19:31:31 +03:00
.gitignore First commit 2018-05-21 23:55:48 +03:00
.npmignore Prepare for publishing to npm registry 2018-05-29 20:01:34 +03:00
CC0 Switch to CC0 license 2019-09-14 19:31:12 +03:00
README.md Fix typo in the example program 2018-05-29 20:17:42 +03:00
api.md Document the API 2018-05-27 13:39:43 +03:00
architecture.md Document the architecture of Gir 2018-05-27 13:55:26 +03:00
brainfuck.md Support all the types of EOF 2018-05-27 12:56:02 +03:00
gir.html Move Gir to use modules 2018-05-27 20:54:59 +00:00
gir.js Let's not accidentally be quadratic in : 2019-09-14 19:28:26 +03:00
ir.md Document writeInt, readInt, breakPoint 2018-05-27 12:32:18 +03:00
ircbot.js Also replace DEL with its graphical equivalent 2018-06-25 23:11:08 +03:00
optimizations.md Update documentation 2018-05-25 23:21:29 +03:00
package.json Bump version number 2019-09-14 19:31:31 +03:00

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?