Befunge93

Befunge93

Creates a new Befunge93 interpreter

Constructor

new Befunge93(onStackChangeopt, onOutputopt, onCellChangeopt, onStepopt, onInputopt)

Source:
Parameters:
Name Type Attributes Default Description
onStackChange Befunge93~onStackChange <optional>
null

Called when the stack is updated (pushed or popped). Supplies 1 arg, current stack

onOutput Befunge93~onOutput <optional>
null

Called when output happens (, or . commands). Supplies 1 arg, the generated output

onCellChange Befunge93~onCellChange <optional>
null

Called when program is changed (p command) Supplies 3 args, current x, current y, and the new value of the cell

onStep Befunge93~onStep <optional>
null

Called when the interpreter makes a step (changing program cursor). Supplies 2 args the current X and Y values

onInput Befunge93~onInput <optional>
null

Called when the interpreter needs user input. Supplies 1 arg, prompt message

Methods

(private) _onCellChange()

Source:

(private) _onInput()

Source:

(private) _onOutput()

Source:

(private) _onStackChange()

Source:

(private) _onStep()

Source:

(private) add()

Source:

(private) bridge()

Source:

(private) discard()

Source:

(private) divide()

Source:

(private) down()

Source:

(private) duplicate()

Source:

(private) get()

Source:

(private) getToken()

Source:

(private) greaterThan()

Source:

(private) horizontalIf()

Source:

(private) inAscii()

Source:

(private) inInt()

Source:

(private) init()

Source:

(private) left()

Source:

(private) modulo()

Source:

(private) multiply()

Source:

(private) not()

Source:

(private) outAscii()

Source:

(private) outInt()

Source:

(private) parseToken()

Source:

pause()

Stops executing of the program

Source:

(private) pop()

Source:

(private) push()

Source:

(private) pushHexValueToStack()

Source:

(private) put()

Source:

(private) randomDirection()

Source:

reset()

Resets the interpreter to default state

Source:

resume()

Allows execution of the program to continue. Does NOT actually execute any part of the program

Source:
Source:

run(program, resetopt, onTickopt)

Source:
Parameters:
Name Type Attributes Default Description
program string

The program to be run

reset boolean <optional>
false

Reset interpreter to default before running?

onTick function <optional>
null

Called every tick. Useful for benchmarking programs

(private) step()

Source:

stepInto()

Source:

(private) subtract()

Source:

(private) swap()

Source:

(private) terminateProgram()

Source:

(private) toggleStringMode()

Source:

(private) up()

Source:

(private) verticalIf()

Source:

(private, static) isHexDigit()

Source:

Type Definitions

onCellChange(x, y, newValue)

Source:
Parameters:
Name Type Description
x number

The changed cell's x position

y number

The changed cell's y position

newValue string

The changed cell's new value

onInput(message) → {string}

Called when the interpreter parses "~" or "&".

Source:
Parameters:
Name Type Description
message string

The message that will be displayed to the user; can be replaced by whatever you want

Returns:
Type:
string

Input from the user. If more than 1 character, only first character is used.

onOutput(value)

Called when the interpreter parses "." or ","

Source:
Parameters:
Name Type Description
value string

The value that was output from interpreter

onStackChange(stack)

Called when the stack is changed

Source:
Parameters:
Name Type Description
stack array

The current stack

onStep(x, y)

Called when the interpreter's cursor position is changed

Source:
Parameters:
Name Type Description
x number

Cursor's current X position

y number

Cursor's current y position

onTick()

Called every tick of the interpreter. Only useful for benchmarking

Source: