Methods
draw()
p5.js draw function, is run every frame to create the desired animation
getJumpEnd() → {Number}
Function to find the matching jump end for a particular left bracket. If not
matching returns undefined.
- Source:
Returns:
- Jump index location
- Type
- Number
getJumpStart() → {Number}
Function to find the matching jump start for a particular right bracket. If
not matching returns undefined.
- Source:
Returns:
- Jump index location
- Type
- Number
getRawProgramTxt() → {String}
Read the string in the input text area and return it
Returns:
- The raw program string
- Type
- String
optimiseProgramTxt(program) → {Array.<String>}
Applies optimisations to the source code of the program
Note that the return type is now an array of strings not chars.
Parameters:
| Name | Type | Description |
|---|---|---|
program |
Array.<char> | The pre processed source code with no comments |
- Source:
Returns:
- The optimised source code
- Type
- Array.<String>
optimiseRLE(program, char) → {Array.<String>}
Function to compress program using run length encoding for a given char. If
a run of more than 1 character is found then the sequence of repeated chars
is replaced with the length of the sequence then the char. EG
optimiseRLE("++++", "+") -> Returns "4+""
Note that the return type is now an array of strings not chars.
Parameters:
| Name | Type | Description |
|---|---|---|
program |
Array.<Char> | Array of source code characters |
char |
char | The character to compress |
- Source:
Returns:
- Returns array of RLE compressed source code
- Type
- Array.<String>
parse(programText) → {Array.<BFInstruction>}
A function to parse the optimised source code into BFInstruction objects
Parameters:
| Name | Type | Description |
|---|---|---|
programText |
Array.<char> | The source code |
- Source:
Returns:
- The list of instructions
- Type
- Array.<BFInstruction>
preProcess(rawProgramtext) → {String}
A function to remove comments and excess white space from the source code.
Parameters:
| Name | Type | Description |
|---|---|---|
rawProgramtext |
String | The raw source code |
- Source:
Returns:
- The preprocessed source code
- Type
- String
run()
Run the current BF program that is in the input text area
setup()
p5.js setup function, creates canvas.