Update jspp.js
This commit is contained in:
parent
b64fd18b61
commit
fc5cb75956
1 changed files with 7 additions and 5 deletions
12
jspp.js
12
jspp.js
|
@ -3,6 +3,11 @@
|
||||||
// Now Maintained by Sneed Group
|
// Now Maintained by Sneed Group
|
||||||
// Licensed under Sammy Public License with <3
|
// Licensed under Sammy Public License with <3
|
||||||
|
|
||||||
|
function getBrainfuckInput() {
|
||||||
|
const input = prompt("Enter a character (for Brainfuck input):");
|
||||||
|
return input ? input.charCodeAt(0) : 0; // Returns the ASCII value of the character, or 0 if cancelled
|
||||||
|
}
|
||||||
|
|
||||||
class JSPlusPlus {
|
class JSPlusPlus {
|
||||||
static General = class {
|
static General = class {
|
||||||
|
|
||||||
|
@ -18,10 +23,7 @@ class JSPlusPlus {
|
||||||
const output = [];
|
const output = [];
|
||||||
|
|
||||||
// Input handling: A simple function to get one character from the user
|
// Input handling: A simple function to get one character from the user
|
||||||
function getInput() {
|
|
||||||
const input = prompt("Enter a character (for Brainfuck input):");
|
|
||||||
return input ? input.charCodeAt(0) : 0; // Returns the ASCII value of the character, or 0 if cancelled
|
|
||||||
}
|
|
||||||
|
|
||||||
while (codePointer < code.length) {
|
while (codePointer < code.length) {
|
||||||
const command = code[codePointer];
|
const command = code[codePointer];
|
||||||
|
@ -43,7 +45,7 @@ class JSPlusPlus {
|
||||||
output.push(String.fromCharCode(memory[pointer])); // Output the character at the current pointer
|
output.push(String.fromCharCode(memory[pointer])); // Output the character at the current pointer
|
||||||
break;
|
break;
|
||||||
case ',':
|
case ',':
|
||||||
memory[pointer] = getInput(); // Read input from the user and store it in memory[pointer]
|
memory[pointer] = getBrainfuckInput(); // Read input from the user and store it in memory[pointer]
|
||||||
break;
|
break;
|
||||||
case '[':
|
case '[':
|
||||||
if (memory[pointer] === 0) {
|
if (memory[pointer] === 0) {
|
||||||
|
|
Loading…
Reference in a new issue