function interpret() {
    if (!this.code) throw new ParserError("Empty program", 0);

    const codeLength = this.code.length;
    let calc = 0;

    progloop:
    while (this.pc < codeLength) {
        const char = this.code.charAt(this.pc);
        
        switch (char) {
            case " ":
                calc++;
                break;

            case "+":
                if (calc === 0) {
                    throw new ParserError("Invalid operation", this.pc);
                } else if (calc < 5) {
                    (OP_BASIC[calc]).call(this);
                } else {
                    pushn.call(this, calc - 5);
                }

                calc = 0;
                break;

            case "*":
                (OP_ARITHMATIC[calc % OP_ARITHMATIC.length]).call(this);
                calc = 0;
                break;

            case ".":
                (OP_PRINT[calc % OP_PRINT.length]).call(this);
                calc = 0;
                break;

            case ",":
                (OP_READ[calc % OP_READ.length]).call(this);
                calc = 0;
                break progloop;

            case "`":
                if (this.labels[calc]) {
                    throw new ParserError("Duplicate label " + calc, this.pc);
                }

                this.labels[calc] = this.pc;
                calc = 0;
                break;

            case "'":
                let label = calc;
                let jump = this.labels[label];

                if (!jump) {
                    throw new ParserError("Unrecognized label " + calc, this.pc);
                }

                jnz.call(this, jump);
                calc = 0;
                break;

            default:
                break;
        }

        this.pc++;
    }
}
/**
 * Interpret a given string of code and return an array of operations.
 */
Interpret a given string of code and return an array of operations.
Interpret a given string of code and return an array of operations .
function interpret() {
    if (!this.code) throw new ParserError("Empty program", 0);
    const codeLength = this.code.length;
    let calc = 0;
    progloop:
    while (this.pc < codeLength) {
        const char = this.code.charAt(this.pc);
        switch (char) {
            case " ":
                calc++;
                break;
            case "+":
                if (calc === 0) {
                    throw new ParserError("Invalid operation", this.pc);
                } else if (calc < 5) {
                    (OP_BASIC[calc]).call(this);
                } else {
                    pushn.call(this, calc - 5);
                }
                calc = 0;
                break;
            case "*":
                (OP_ARITHMATIC[calc % OP_ARITHMATIC.length]).call(this);
                calc = 0;
                break;
            case ".":
                (OP_PRINT[calc % OP_PRINT.length]).call(this);
                calc = 0;
                break;
            case ",":
                (OP_READ[calc % OP_READ.length]).call(this);
                calc = 0;
                break progloop;
            case "`":
                if (this.labels[calc]) {
                    throw new ParserError("Duplicate label " + calc, this.pc);
                }
                this.labels[calc] = this.pc;
                calc = 0;
                break;
            case "'":
                let label = calc;
                let jump = this.labels[label];
                if (!jump) {
                    throw new ParserError("Unrecognized label " + calc, this.pc);
                }
                jnz.call(this, jump);
                calc = 0;
                break;
            default:
                break;
        }
        this.pc++;
    }
}
function interpret ( ) { if ( ! this . code ) throw new ParserError ( "Empty program" , 0 ) ; const codeLength = this . code . length ; let calc = 0 ; progloop : while ( this . pc < codeLength ) { const char = this . code . charAt ( this . pc ) ; switch ( char ) { case " " : calc ++ ; break ; case "+" : if ( calc === 0 ) { throw new ParserError ( "Invalid operation" , this . pc ) ; } else if ( calc < 5 ) { ( OP_BASIC [ calc ] ) . call ( this ) ; } else { pushn . call ( this , calc - 5 ) ; } calc = 0 ; break ; case "*" : ( OP_ARITHMATIC [ calc % OP_ARITHMATIC . length ] ) . call ( this ) ; calc = 0 ; break ; case "." : ( OP_PRINT [ calc % OP_PRINT . length ] ) . call ( this ) ; calc = 0 ; break ; case "," : ( OP_READ [ calc % OP_READ . length ] ) . call ( this ) ; calc = 0 ; break progloop ; case "`" : if ( this . labels [ calc ] ) { throw new ParserError ( "Duplicate label " + calc , this . pc ) ; } this . labels [ calc ] = this . pc ; calc = 0 ; break ; case "'" : let label = calc ; let jump = this . labels [ label ] ; if ( ! jump ) { throw new ParserError ( "Unrecognized label " + calc , this . pc ) ; } jnz . call ( this , jump ) ; calc = 0 ; break ; default : break ; } this . pc ++ ; } }
Interpret a given string of code and return an array of operations.
Interpret a given string of code and return an array of operations .