brainfucker.js
v0.0.5
Published
brainfuck JS interpreter for node and browsers
Readme
brainfucker.js
a brainfuck interpreter for nodejs and browsers.
brainfucker.js is a powerful interpreter for brainfuck with many features:
ngenables a superset of brainfuck with the addition of two symbols(!and?) to write and read a number from input.reversefuckswitch the interpreter to reversefuck mode where the semantic of all the commands are inverteddata='datum'set the initial environment to be equal to 'datum' instead of all zerosoenvoutputs the environment resulting at the end of the bf computation instead of the standard output (!.)
It can be used as a node module or included directly into a web page.
install
$ npm install brainfucker.jsor
$ git clone <this repo>
$ npm installbrainfucker.js as a node module
var bf=require('brainfucker.js');
let x=bf.run('+++![>+<-]>!',null,true);
console.log(x.out);the run parameters are (in order):
- the bf code
- the initial enviromnent (optional)
- the ng expensions (optional)
- the reversefuck mode (optional)
brainfucker.js into a web page
$ npm installor
$ npm run webto generate the files that you can include in a web page. either:
- ./web/brainfucker.js
- ./web/brainfucker.min.js
and then just copy the file to your web project and link to it:
<script src="path_to_file/brainfucker.min.js"></script>you can put your brainfuck code into a brainfuck tag. All the brainfuck tags will be processed:
<html>
<head>
</head>
<body>
pippo<br>
<brainfuck ng>
+++[>+<-]>!
hhj
</brainfuck>
<br>
<brainfuck ng data="fff" oenv>
>+
</brainfuck>
<br>
<brainfuck ng reversefuck>
---]<->+[<<>?
</brainfuck>
<script src="brainfucker.min.js"></script>
or
<script>
var x=new BrainFuckerJS();
var a=x.run('+++!',null,true);
console.log(a.out);
</body>
</html>You can pass the oprions as a tag arguments.
Or you can use brainfucker.js as in the node module by refering to its class.
That's all falks!
_____
< bye >
-----
\ ^__^
\ (oo)\_______
(__)\ )\/\
||----w |
|| ||
