Befunge93
Befunge93 is an interpreter written in JavaScript for the Befunge93 esoteric programming language.
Installation
Befunge93 is available on npm!
npm install befunge93
Getting started
To run a Befunge program, just create a new interpreter and call #run with your program as the argument.
#run returns a promise that is resolved when the program terminates (by parsing a "@").
const Befunge = ;let befunge = ; befunge ;
Outputs: "9 8 7 6 5 4 3 2 1 "
Advanced Usage
Befunge93 provides you with a few callbacks to hook into the interpreter.
In order to provide the interpreter with input/output, you must supply the #onInput and #onOutput callbacks.
#onInput
Called when the interpreter needs input from the user. Ie. the ~ and & commands.
Example:
befunge { return ;};
#onOutput
Called when the interpreter outputs a character. Ie. the , and . commands
Example:
befunge { console;};
#onStep
Called when the program's cursor changes.
Example:
befunge { console; console;};
#onStackChange
Called when the stack is updated.
Example:
befunge { console;};
#onCellChange
Called when a cell is updated by the p command.
Example:
befunge { console;};